← Torna al blog

Dev Tips

Un trucchetto al giorno leva le complicazioni di torno! Piccole "scorciatoie" che possono facilitare la vita degli sviluppatori e far risparmiare tempo...e righe di codice.

125

Reduce motion sickness with CSS

2023-10-27

1.animation {
2  animation: amazing-animation 1s linear infinite both;
3  background-color: red;
4}
5
6/* Change animation to avoid vestibular motion triggers */
7@media (prefers-reduced-motion) { 
8  .animation {
9    animation: accessible-animation 4s linear infinite both; 
10    background-color: green;
11  }
12}
124

Reduce motion sickness with CSS

2023-10-27

1.animation {
2  animation: amazing-animation 1s linear infinite both;
3  background-color: red;
4}
5/* Change animation to avoid vestibular motion triggers. */
6@media (prefers-reduced-motion) { 	
7  .animation { 	
8    animation: accessible-animation 4s linear infinite both;
9      background-color: green;  
10  } 
11}
123

How to set entire document editable

2021-10-04

1// JS Tip of the Day
2// How to set entire document editable
3
4document.designMode = 'on'; // use it with Developer Tools Console.
122

Set the primitive value of an object - easy way

2021-08-02

1// JS Tip of the Day
2// Set the primitive value of an object - easy way
3
4class Hero {
5	constructor(hero = 'Batman') {
6      this.hero = hero;
7    }
8
9    valueOf() {
10		return `I'm ${this.hero}`;
11	}
12}
13
14console.log(new Hero()); // { hero: 'Batman' }
15console.log(`${new Hero()}!!!!`); // I'm Batman!
121

Import and parse JSON with modules (Chrome 91+)

2021-07-29

1// JS Tip of the Day
2// Import and parse JSON with modules (Chrome 91+)
3
4/* heroes.json
5{
6  "heroes": [
7    { "name": "Batman", "weapon": "Batarang" },
8    { "name": "Superman", "weapon": "himself" }
9  ]
10}
11*/
12
13import heroes from './heroes.json' assert { type: "json" };
14console.log(heroes); // { heroes: Array(2) } 
15// or
16const heroesModule = await import('../db.json', { assert: { type: 'json' } });
17console.log(heroesModule.default); // { heroes: Array(2) }
18
19
20/*
21  NB: The new import assertions feature allows module import statements 
22  to include additional information.
23  For instance, if you use the assertions, it fails if responds with 
24  a non-JSON MIME type.
25*/

Contattaci.

Hai in mente un progetto e vorresti realizzarlo?
Sei interessato a migliorare le competenze del tuo team in ambito di programmazione e sviluppo?
Oppure vuoi semplicemente prendere prendere un caffè con noi e vedere la nostra collezione di Action Figure, allora scrivici tramite questo form.

Se, invece, vuoi far parte del team, guarda le nostre offerte di lavoro.

Questo sito è protetto da reCAPTCHA e si applicano le Norme sulla privacy e i Termini di servizio di Google.