feat: skip type writing animation before 10min has passed
This commit is contained in:
parent
74a0771f01
commit
8801b8c020
|
@ -50,6 +50,25 @@
|
|||
}
|
||||
|
||||
protected mounted() {
|
||||
let last = 0;
|
||||
|
||||
// check if already animated in the last 10 min
|
||||
const typed = localStorage.getItem('typed')
|
||||
const parsed = parseInt(typed!) as number
|
||||
if( !isNaN(parsed) ){
|
||||
last = parsed;
|
||||
}
|
||||
|
||||
const now = new Date().getTime();
|
||||
const diff_sec = (now - last) / 1e3;
|
||||
|
||||
const threshold = 10 * 60;
|
||||
|
||||
// skip animation if already done less than 10min ago
|
||||
if( diff_sec < threshold ){
|
||||
return;
|
||||
}
|
||||
|
||||
const t1 = new TypeWriter( this.$refs['text1'] as HTMLElement )
|
||||
const t2 = new TypeWriter( this.$refs['text2'] as HTMLElement )
|
||||
const t3 = new TypeWriter( this.$refs['text3'] as HTMLElement )
|
||||
|
@ -68,6 +87,11 @@
|
|||
setTimeout( () => t3.animate(4000), 6000 );
|
||||
// wait 10s, anim 3s
|
||||
setTimeout( () => t4.animate(3000), 10000 );
|
||||
|
||||
// local storage: store that we animated once
|
||||
setTimeout( () => {
|
||||
localStorage.setItem('typed', `${new Date().getTime()}`);
|
||||
}, 13000 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue