-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHypeAnimationFrame.min.js
7 lines (7 loc) · 1.15 KB
/
HypeAnimationFrame.min.js
1
2
3
4
5
6
7
/*
Hype AnimationFrame 1.3
copyright (c) 2019 Max Ziebell, (https://maxziebell.de). MIT-license
*/
!1==="HypeAnimationFrame"in window&&(window.HypeAnimationFrame=function(){function e(a,c){window.cancelAnimationFrame(d[a][c]);delete d[a][c]}function f(a){for(var c in d[a])e(a,c)}var d={};!1==="HYPE_eventListeners"in window&&(window.HYPE_eventListeners=[]);window.HYPE_eventListeners.push({type:"HypeDocumentLoad",callback:function(a,c,l){var g=a.documentId();d[g]={};a.startAnimationFrame=function(a,b){b=b?b:{};var c=b.id||a,e=b.scope||this;if(!d[g][c]){if(b.framerate)var f=1E3/b.framerate,k=-1,h=
function(b){now=performance.now();elapsed=now-k;elapsed>f&&(k=now-elapsed%f,a.call(e,b));d[g][c]=window.requestAnimationFrame(h)};else h=function(b){a.call(e,b);d[g][c]=window.requestAnimationFrame(h)};h()}};a.stopAnimationFrame=function(a){e(g,a)};a.stopAllAnimationFrames=function(){f(g)}}});window.HYPE_eventListeners.push({type:"HypeSceneUnload",callback:function(a,c,d){a.stopAllAnimationFrames()}});return{version:"1.3",stopAnimationFrameByHypeDocumentId:e,stopAllAnimationFramesByHypeDocumentId:f,
stopAllAnimationFrames:function(){for(var a in d)f(a),d[a]={}}}}());