From 70a0aa24f2ea11a8923b17e246c24ca43f7b4d3b Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 28 Oct 2020 22:42:20 -0400 Subject: [PATCH 1/2] Experimental animation tracking --- src/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7eccff6..3624a94 100644 --- a/src/index.js +++ b/src/index.js @@ -1004,7 +1004,6 @@ function init() { 'animationstart', 'transitionstart', 'transitionend', - 'transitionrun', 'transitioncancel', 'mouseover', 'mouseout', @@ -1018,6 +1017,25 @@ function init() { function updateFromEvent(e) { let t = e.target; + const type = e.type; + if (type === 'animationstart' || type === 'transitionstart') { + const s = this.$$paintAnimating = (this.$$paintAnimating || 0) + 1; + if (s === 1) { + // Firefox ~68 didn't support Event.path + const p = []; + do { if (t.nodeType === 1) p.push(t); } while ((t = t.parentNode)); + let frame = () => { + if (!this.$$paintAnimating) return frame = null; + for (let i=p.length; i--; ) queueUpdate(p[i]); + this.$$paintRaf = (self.requestAnimationFrame || Object)(frame); + }; + frame(); + } + return; + } + if ((type === 'animationend' || type === 'transitionend' || type === 'transitioncancel') && --this.$$paintAnimating === 0) { + (self.cancelAnimationFrame || Object)(this.$$paintRaf); + } while (t) { if (t.nodeType === 1) queueUpdate(t); t = t.parentNode; From c8edb0eda7f7c3bab9eeef02ac4f0fb77c295d02 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Wed, 28 Oct 2020 22:50:12 -0400 Subject: [PATCH 2/2] fire raf first --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3624a94..f038c54 100644 --- a/src/index.js +++ b/src/index.js @@ -1026,8 +1026,8 @@ function init() { do { if (t.nodeType === 1) p.push(t); } while ((t = t.parentNode)); let frame = () => { if (!this.$$paintAnimating) return frame = null; - for (let i=p.length; i--; ) queueUpdate(p[i]); this.$$paintRaf = (self.requestAnimationFrame || Object)(frame); + for (let i=p.length; i--; ) queueUpdate(p[i]); }; frame(); }