← 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.

126

One-shot handling of an event

2023-10-29

1// <button id="one-shot-hero-button">Batman! Help me!</button>
2
3const fakeHeroEl = document.getElementById('one-shot-hero-button');
4fakeHeroEl.addEventListener('click', function(event) {
5  console.log('Call me one time and no more!');
6}, {once: true});
7
8fakeHeroEl.click() // Call me one time and no more!
9fakeHeroEl.click() // 
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!

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.