Skip to content

Commit

Permalink
Update painted elements in response to events that have the ability t…
Browse files Browse the repository at this point in the history
…o impact styles
  • Loading branch information
developit committed Oct 29, 2020
1 parent 19a49b3 commit 25b45cd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,34 @@ function init() {
});
}

const OPTS = { passive: true };

[
'animationiteration',
'animationend',
'animationstart',
'transitionstart',
'transitionend',
'transitionrun',
'transitioncancel',
'mouseover',
'mouseout',
'mousedown',
'mouseup',
'focus',
'blur'
].forEach(event => {
addEventListener(event, updateFromEvent, OPTS);
});

function updateFromEvent(e) {
let t = e.target;
while (t) {
if (t.nodeType === 1) queueUpdate(t);
t = t.parentNode;
}
}

update();
}

Expand Down

0 comments on commit 25b45cd

Please sign in to comment.