-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathanimations.js
More file actions
33 lines (24 loc) · 795 Bytes
/
animations.js
File metadata and controls
33 lines (24 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function highlightElement(element){
element.style.setProperty('background-color', '#badbcc', 'important');
await sleep(50);
element.style['transition'] = 'background-color 0.2s ease-in';
element.style['backgroundColor'] = '';
await sleep(350);
element.style['transition'] = '';
}
async function highlightSelection(){
let head = document.head;
let styleEl = document.createElement('style');
styleEl.type = 'text/css';
styleEl.appendChild(document.createTextNode(`
::selection {
background-color: #badbcc !important;
}
`));
head.appendChild(styleEl);
await sleep(400); // FIXME background animation removed because works strange
head.removeChild(styleEl);
}