@lottiefiles/lottie-interactivity
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -6,2 +6,10 @@ # Changelog | ||
## [1.3.2](https://github.com/LottieFiles/lottie-interactivity/compare/v1.3.1...v1.3.2) (2022-01-10) | ||
### Bug Fixes | ||
* **interactions:** added additional comments ([5a77a9c](https://github.com/LottieFiles/lottie-interactivity/commit/5a77a9c9169886846acc62ffebde48e0c3ace064)) | ||
* **interactions:** added mobile support for interactions ([b8e3a9e](https://github.com/LottieFiles/lottie-interactivity/commit/b8e3a9e1c87683559b301dd3d364fb49154c4092)) | ||
## [1.3.1](https://github.com/LottieFiles/lottie-interactivity/compare/v1.3.0...v1.3.1) (2022-01-05) | ||
@@ -8,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function a(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function i(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var r={player:"lottie-player"},o="[lottieInteractivity]:",s=function(){function s(){var n=this,A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,M=A.actions,C=A.container,T=A.mode,H=A.player,O=a(A,["actions","container","mode","player"]);if(t(this,s),l.set(this,{writable:!0,value:function(){if(n.player){var e=function(){n.player.addEventListener("enterFrame",i(n,g)),n.container.addEventListener("mouseenter",i(n,L)),n.container.addEventListener("mouseleave",i(n,E))};n.stateHandler.set("loop",(function(){n.actions[n.interactionIdx].loop?n.player.loop=parseInt(n.actions[n.interactionIdx].loop)-1:n.player.loop=!0,n.player.autoplay=!0})),n.stateHandler.set("autoplay",(function(){n.player.loop=!1,n.player.autoplay=!0})),n.stateHandler.set("click",(function(){n.player.loop=!1,n.player.autoplay=!1,n.container.addEventListener("click",i(n,c))})),n.stateHandler.set("hover",(function(){n.player.loop=!1,n.player.autoplay=!1,n.container.addEventListener("mouseenter",i(n,c))})),n.transitionHandler.set("click",(function(){n.container.addEventListener("click",i(n,d))})),n.transitionHandler.set("hover",(function(){n.container.addEventListener("mouseenter",i(n,d))})),n.transitionHandler.set("hold",e),n.transitionHandler.set("pauseHold",e),n.transitionHandler.set("repeat",(function(){n.player.loop=!0,n.player.autoplay=!0;n.player.addEventListener("loopComplete",(function e(){i(n,h).call(n,{handler:e})}))})),n.transitionHandler.set("onComplete",(function(){"loop"===n.actions[n.interactionIdx].state?n.player.addEventListener("loopComplete",i(n,m)):n.player.addEventListener("complete",i(n,m))})),n.transitionHandler.set("seek",(function(){n.player.stop(),n.player.addEventListener("enterFrame",i(n,f)),n.container.addEventListener("mousemove",i(n,y)),n.container.addEventListener("touchmove",i(n,u)),n.container.addEventListener("mouseout",i(n,v))}))}}}),c.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].forceFlag;e||!0!==n.player.isPaused?e&&i(n,k).call(n,!0):i(n,k).call(n,!0)}}),p.set(this,{writable:!0,value:function(){0===n.clickCounter?(n.player.play(),n.clickCounter++):(n.clickCounter++,n.player.setDirection(-1*n.player.playDirection),n.player.play())}}),d.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].forceFlag;if("chain"===n.mode){if(n.actions[n.interactionIdx].count){var t=parseInt(n.actions[n.interactionIdx].count);if(n.clickCounter<t-1)return void(n.clickCounter+=1)}return n.clickCounter=0,n.container.removeEventListener("click",i(n,d)),n.container.removeEventListener("mouseenter",i(n,d)),void i(n,b).call(n)}e||!0!==n.player.isPaused?e&&n.player.goToAndPlay(0,!0):n.player.goToAndPlay(0,!0)}}),y.set(this,{writable:!0,value:function(e){i(n,P).call(n,e.clientX,e.clientY)}}),u.set(this,{writable:!0,value:function(e){e.cancelable&&e.preventDefault(),i(n,P).call(n,e.touches[0].clientX,e.touches[0].clientY)}}),v.set(this,{writable:!0,value:function(){i(n,P).call(n,-1,-1)}}),m.set(this,{writable:!0,value:function(){"loop"===n.actions[n.interactionIdx].state?n.player.removeEventListener("loopComplete",i(n,m)):n.player.removeEventListener("complete",i(n,m)),i(n,b).call(n)}}),h.set(this,{writable:!0,value:function(e){var t=e.handler,a=1;n.actions[n.interactionIdx].repeat&&(a=n.actions[n.interactionIdx].repeat),n.playCounter>=a-1?(n.playCounter=0,n.player.removeEventListener("loopComplete",t),n.player.loop=!1,n.player.autoplay=!1,i(n,b).call(n)):n.playCounter+=1}}),f.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].frames;e&&n.player.currentFrame>=parseInt(e[1])-1&&(n.player.removeEventListener("enterFrame",i(n,f)),n.container.removeEventListener("mousemove",i(n,y)),n.container.removeEventListener("mouseout",i(n,v)),setTimeout(i(n,b),0))}}),g.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].frames;(e&&n.player.currentFrame>=e[1]||n.player.currentFrame>=n.player.totalFrames-1)&&(n.player.removeEventListener("enterFrame",i(n,g)),n.container.removeEventListener("mouseenter",i(n,L)),n.container.removeEventListener("mouseleave",i(n,E)),n.player.pause(),i(n,b).call(n))}}),L.set(this,{writable:!0,value:function(){-1!==n.player.playDirection&&0!==n.player.currentFrame&&"pauseHold"!==n.actions[n.interactionIdx].transition&&"pauseHold"!==n.actions[0].type||(n.player.setDirection(1),n.player.play())}}),E.set(this,{writable:!0,value:function(){"hold"===n.actions[n.interactionIdx].transition||"hold"===n.actions[0].type?(n.player.setDirection(-1),n.player.play()):"pauseHold"!==n.actions[n.interactionIdx].transition&&"pauseHold"!==n.actions[0].type||n.player.pause()}}),w.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].state;"hover"!==e&&"click"!==e||(n.container.removeEventListener("click",i(n,c)),n.container.removeEventListener("mouseenter",i(n,c)))}}),b.set(this,{writable:!0,value:function(){var e=n.interactionIdx;i(n,w).call(n);var t=n.actions[n.interactionIdx].jumpTo;t?t>=0&&t<n.actions.length?(n.interactionIdx=t,i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx=0,n.player.goToAndStop(0,!0),i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx++,n.interactionIdx>=n.actions.length?n.actions[n.actions.length-1].reset?(n.interactionIdx=0,n.player.goToAndStop(0,!0),i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx=n.actions.length-1,i(n,I).call(n,{ignorePath:!1})):i(n,I).call(n,{ignorePath:!1})),n.container.dispatchEvent(new CustomEvent("transition",{bubbles:!0,composed:!0,detail:{oldIndex:e,newIndex:n.interactionIdx}}))}}),k.set(this,{writable:!0,value:function(e){var t=n.actions[n.interactionIdx].frames;if(!t)return n.player.resetSegments(!0),void n.player.goToAndPlay(0,!0);"string"==typeof t?n.player.goToAndPlay(t,e):n.player.playSegments(t,e)}}),x.set(this,{writable:!0,value:function(){var t=n.actions[n.interactionIdx].path;if(!t)if("object"===e(n.enteredPlayer)&&"AnimationItem"===n.enteredPlayer.constructor.name){if(t=n.enteredPlayer,n.player===t)return void i(n,I).call(n,{ignorePath:!0})}else{var a=(t=n.loadedAnimation).substr(t.lastIndexOf("/")+1);if(a=a.substr(0,a.lastIndexOf(".json")),n.player.fileName===a)return void i(n,I).call(n,{ignorePath:!0})}var r=n.container.getBoundingClientRect(),s="width: "+r.width+"px !important; height: "+r.height+"px !important; background: "+n.container.style.background;if(n.container.setAttribute("style",s),"object"!==e(n.enteredPlayer)||"AnimationItem"!==n.enteredPlayer.constructor.name){if("string"==typeof n.enteredPlayer){var l=document.querySelector(n.enteredPlayer);l&&"LOTTIE-PLAYER"===l.nodeName&&(n.attachedListeners||(l.addEventListener("ready",(function(){n.container.style.width="",n.container.style.height=""})),l.addEventListener("load",(function(){n.player=l.getLottie(),i(n,I).call(n,{ignorePath:!0})})),n.attachedListeners=!0),l.load(t))}else n.enteredPlayer instanceof HTMLElement&&"LOTTIE-PLAYER"===n.enteredPlayer.nodeName&&(n.attachedListeners||(n.enteredPlayer.addEventListener("ready",(function(){n.container.style.width="",n.container.style.height=""})),n.enteredPlayer.addEventListener("load",(function(){n.player=n.enteredPlayer.getLottie(),i(n,I).call(n,{ignorePath:!0})})),n.attachedListeners=!0),n.enteredPlayer.load(t));if(!n.player)throw new Error("".concat(o," Specified player is invalid."),n.enteredPlayer)}else{if(!window.lottie)throw new Error("".concat(o," A Lottie player is required."));n.stop(),n.player.destroy(),n.container.innerHTML="","object"===e(t)&&"AnimationItem"===t.constructor.name?n.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,animationData:t.animationData,container:n.container}):n.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,path:t,container:n.container}),n.player.addEventListener("DOMLoaded",(function(){n.container.style.width="",n.container.style.height="",i(n,I).call(n,{ignorePath:!0})}))}n.clickCounter=0,n.playCounter=0}}),I.set(this,{writable:!0,value:function(e){var t=e.ignorePath,a=n.actions[n.interactionIdx].state,r=n.actions[n.interactionIdx].transition,o=n.actions[n.interactionIdx].path,s=n.stateHandler.get(a),l=n.transitionHandler.get(r),c=n.actions[n.interactionIdx].speed?n.actions[n.interactionIdx].speed:1,p=n.actions[n.interactionIdx].delay?n.actions[n.interactionIdx].delay:0;t||!(o||n.actions[n.actions.length-1].reset&&0===n.interactionIdx)?setTimeout((function(){s?s.call():"none"===a&&(n.player.loop=!1,n.player.autoplay=!1),l&&l.call(),n.player.autoplay&&(n.player.resetSegments(!0),i(n,k).call(n,!0)),n.player.setSpeed(c)}),p):i(n,x).call(n)}}),P.set(this,{writable:!0,value:function(e,t){if(-1!==e&&-1!==t){var a=n.getContainerCursorPosition(e,t);e=a.x,t=a.y}var i=n.actions.find((function(n){var a=n.position;if(a){if(Array.isArray(a.x)&&Array.isArray(a.y))return e>=a.x[0]&&e<=a.x[1]&&t>=a.y[0]&&t<=a.y[1];if(!Number.isNaN(a.x)&&!Number.isNaN(a.y))return e===a.x&&t===a.y}return!1}));if(i)if("seek"===i.type||"seek"===i.transition){var r=(e-i.position.x[0])/(i.position.x[1]-i.position.x[0]),o=(t-i.position.y[0])/(i.position.y[1]-i.position.y[0]);n.player.playSegments(i.frames,!0),i.position.y[0]<0&&i.position.y[1]>1?n.player.goToAndStop(Math.floor(r*n.player.totalFrames),!0):n.player.goToAndStop(Math.ceil((r+o)/2*n.player.totalFrames),!0)}else"loop"===i.type?n.player.playSegments(i.frames,!0):"play"===i.type?(!0===n.player.isPaused&&n.player.resetSegments(),n.player.playSegments(i.frames)):"stop"===i.type&&(n.player.resetSegments(!0),n.player.goToAndStop(i.frames[0],!0))}}),S.set(this,{writable:!0,value:function(){var e=n.getContainerVisibility(),t=n.actions.find((function(t){var n=t.visibility;return e>=n[0]&&e<=n[1]}));if(t)if("seek"===t.type){var a=t.frames[0],i=2==t.frames.length?t.frames[1]:n.player.totalFrames-1;null!==n.assignedSegment&&(n.player.resetSegments(!0),n.assignedSegment=null),n.player.goToAndStop(a+Math.round((e-t.visibility[0])/(t.visibility[1]-t.visibility[0])*(i-a)),!0)}else"loop"===t.type?(n.player.loop=!0,(null===n.assignedSegment||n.assignedSegment!==t.frames||!0===n.player.isPaused)&&(n.player.playSegments(t.frames,!0),n.assignedSegment=t.frames)):"play"===t.type?n.scrolledAndPlayed||(n.scrolledAndPlayed=!0,n.player.resetSegments(!0),n.player.play()):"stop"===t.type&&n.player.goToAndStop(t.frames[0],!0)}}),this.enteredPlayer=H,"object"!==e(H)||"AnimationItem"!==H.constructor.name){if("string"==typeof H){var W=document.querySelector(H);W&&"LOTTIE-PLAYER"===W.nodeName&&(H=W.getLottie())}else H instanceof HTMLElement&&"LOTTIE-PLAYER"===H.nodeName&&(H=H.getLottie());if(!H){var F=o+"Specified player:"+H+" is invalid.";throw new Error(F)}}"string"==typeof C&&(C=document.querySelector(C)),C||(C=H.wrapper),this.player=H,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=C,this.mode=T,this.actions=M,this.options=O,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map}var A,M,C;return A=s,(M=[{key:"getContainerVisibility",value:function(){var e=this.container.getBoundingClientRect(),t=e.top,n=e.height;return(window.innerHeight-t)/(window.innerHeight+n)}},{key:"getContainerCursorPosition",value:function(e,t){var n=this.container.getBoundingClientRect(),a=n.top;return{x:(e-n.left)/n.width,y:(t-a)/n.height}}},{key:"start",value:function(){var e=this;"scroll"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.player.stop(),window.addEventListener("scroll",i(e,S))})):"cursor"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.actions&&1===e.actions.length?"click"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",i(e,d))):"hover"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("mouseenter",i(e,d))):"toggle"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",i(e,p))):"hold"===e.actions[0].type||"pauseHold"===e.actions[0].type?(e.container.addEventListener("mouseenter",i(e,L)),e.container.addEventListener("mouseleave",i(e,E))):"seek"===e.actions[0].type&&(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",i(e,y)),e.container.addEventListener("touchmove",i(e,u)),e.container.addEventListener("mouseout",i(e,v))):(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",i(e,y)),e.container.addEventListener("mouseleave",i(e,v)),i(e,P).call(e,-1,-1))})):"chain"===this.mode&&(this.player.isLoaded?(i(e,l).call(e),e.player.loop=!1,e.player.stop(),i(e,I).call(e,{ignorePath:!1})):this.player.addEventListener("DOMLoaded",(function(){i(e,l).call(e),e.player.loop=!1,e.player.stop(),i(e,I).call(e,{ignorePath:!1})})))}},{key:"redefineOptions",value:function(t){var n=t.actions,i=t.container,r=t.mode,s=t.player,l=a(t,["actions","container","mode","player"]);if(this.stop(),this.player.stop(),this.enteredPlayer=s,"object"!==e(s)||"AnimationItem"!==s.constructor.name){if("string"==typeof s){var c=document.querySelector(s);c&&"LOTTIE-PLAYER"===c.nodeName&&(s=c.getLottie())}else s instanceof HTMLElement&&"LOTTIE-PLAYER"===s.nodeName&&(s=s.getLottie());if(!s)throw new Error(o+"Specified player:"+s+" is invalid.",s)}"string"==typeof i&&(i=document.querySelector(i)),i||(i=s.wrapper),this.player=s,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=i,this.mode=r,this.actions=n,this.options=l,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map,this.start()}},{key:"stop",value:function(){"scroll"===this.mode&&window.removeEventListener("scroll",i(this,S)),"cursor"===this.mode&&(this.container.removeEventListener("click",i(this,d)),this.container.removeEventListener("click",i(this,p)),this.container.removeEventListener("mouseenter",i(this,d)),this.container.addEventListener("touchmove",i(this,u)),this.container.removeEventListener("mousemove",i(this,y)),this.container.removeEventListener("mouseleave",i(this,v))),"chain"===this.mode&&(this.container.removeEventListener("click",i(this,d)),this.container.removeEventListener("click",i(this,c)),this.container.removeEventListener("mouseenter",i(this,d)),this.container.removeEventListener("touchmove",i(this,u)),this.container.removeEventListener("mouseenter",i(this,c)),this.container.removeEventListener("mouseenter",i(this,L)),this.container.removeEventListener("mouseleave",i(this,E)),this.container.removeEventListener("mousemove",i(this,y)),this.container.removeEventListener("mouseout",i(this,v)),this.player.removeEventListener("loopComplete",i(this,m)),this.player.removeEventListener("complete",i(this,m)),this.player.removeEventListener("enterFrame",i(this,f)),this.player.removeEventListener("enterFrame",i(this,g)))}}])&&n(A.prototype,M),C&&n(A,C),s}(),l=new WeakMap,c=new WeakMap,p=new WeakMap,d=new WeakMap,y=new WeakMap,u=new WeakMap,v=new WeakMap,m=new WeakMap,h=new WeakMap,f=new WeakMap,g=new WeakMap,L=new WeakMap,E=new WeakMap,w=new WeakMap,b=new WeakMap,k=new WeakMap,x=new WeakMap,I=new WeakMap,P=new WeakMap,S=new WeakMap,A=function(e){var t=new s(e);return t.start(),t};export default A;export{s as LottieInteractivity,A as create}; | ||
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function a(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function i(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var r={player:"lottie-player"},o="[lottieInteractivity]:",s=function(){function s(){var n=this,A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r,M=A.actions,C=A.container,T=A.mode,H=A.player,O=a(A,["actions","container","mode","player"]);if(t(this,s),l.set(this,{writable:!0,value:function(){if(n.player){var e=function(){n.player.addEventListener("enterFrame",i(n,L)),n.container.addEventListener("mouseenter",i(n,g)),n.container.addEventListener("mouseleave",i(n,E)),n.container.addEventListener("touchstart",i(n,g),{passive:!0}),n.container.addEventListener("touchend",i(n,E),{passive:!0})};n.stateHandler.set("loop",(function(){n.actions[n.interactionIdx].loop?n.player.loop=parseInt(n.actions[n.interactionIdx].loop)-1:n.player.loop=!0,n.player.autoplay=!0})),n.stateHandler.set("autoplay",(function(){n.player.loop=!1,n.player.autoplay=!0})),n.stateHandler.set("click",(function(){n.player.loop=!1,n.player.autoplay=!1,n.container.addEventListener("click",i(n,c))})),n.stateHandler.set("hover",(function(){n.player.loop=!1,n.player.autoplay=!1,n.container.addEventListener("mouseenter",i(n,c)),n.container.addEventListener("touchstart",i(n,c),{passive:!0})})),n.transitionHandler.set("click",(function(){n.container.addEventListener("click",i(n,d))})),n.transitionHandler.set("hover",(function(){n.container.addEventListener("mouseenter",i(n,d)),n.container.addEventListener("touchstart",i(n,d),{passive:!0})})),n.transitionHandler.set("hold",e),n.transitionHandler.set("pauseHold",e),n.transitionHandler.set("repeat",(function(){n.player.loop=!0,n.player.autoplay=!0;n.player.addEventListener("loopComplete",(function e(){i(n,m).call(n,{handler:e})}))})),n.transitionHandler.set("onComplete",(function(){"loop"===n.actions[n.interactionIdx].state?n.player.addEventListener("loopComplete",i(n,h)):n.player.addEventListener("complete",i(n,h))})),n.transitionHandler.set("seek",(function(){n.player.stop(),n.player.addEventListener("enterFrame",i(n,f)),n.container.addEventListener("mousemove",i(n,y)),n.container.addEventListener("touchmove",i(n,u),{passive:!1}),n.container.addEventListener("mouseout",i(n,v))}))}}}),c.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].forceFlag;e||!0!==n.player.isPaused?e&&i(n,k).call(n,!0):i(n,k).call(n,!0)}}),p.set(this,{writable:!0,value:function(){0===n.clickCounter?(n.player.play(),n.clickCounter++):(n.clickCounter++,n.player.setDirection(-1*n.player.playDirection),n.player.play())}}),d.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].forceFlag;if("chain"===n.mode){if(n.actions[n.interactionIdx].count){var t=parseInt(n.actions[n.interactionIdx].count);if(n.clickCounter<t-1)return void(n.clickCounter+=1)}return n.clickCounter=0,n.container.removeEventListener("click",i(n,d)),n.container.removeEventListener("mouseenter",i(n,d)),void i(n,b).call(n)}e||!0!==n.player.isPaused?e&&n.player.goToAndPlay(0,!0):n.player.goToAndPlay(0,!0)}}),y.set(this,{writable:!0,value:function(e){i(n,P).call(n,e.clientX,e.clientY)}}),u.set(this,{writable:!0,value:function(e){e.cancelable&&e.preventDefault(),i(n,P).call(n,e.touches[0].clientX,e.touches[0].clientY)}}),v.set(this,{writable:!0,value:function(){i(n,P).call(n,-1,-1)}}),h.set(this,{writable:!0,value:function(){"loop"===n.actions[n.interactionIdx].state?n.player.removeEventListener("loopComplete",i(n,h)):n.player.removeEventListener("complete",i(n,h)),i(n,b).call(n)}}),m.set(this,{writable:!0,value:function(e){var t=e.handler,a=1;n.actions[n.interactionIdx].repeat&&(a=n.actions[n.interactionIdx].repeat),n.playCounter>=a-1?(n.playCounter=0,n.player.removeEventListener("loopComplete",t),n.player.loop=!1,n.player.autoplay=!1,i(n,b).call(n)):n.playCounter+=1}}),f.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].frames;e&&n.player.currentFrame>=parseInt(e[1])-1&&(n.player.removeEventListener("enterFrame",i(n,f)),n.container.removeEventListener("mousemove",i(n,y)),n.container.removeEventListener("mouseout",i(n,v)),setTimeout(i(n,b),0))}}),L.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].frames;(e&&n.player.currentFrame>=e[1]||n.player.currentFrame>=n.player.totalFrames-1)&&(n.player.removeEventListener("enterFrame",i(n,L)),n.container.removeEventListener("mouseenter",i(n,g)),n.container.removeEventListener("mouseleave",i(n,E)),n.player.pause(),i(n,b).call(n))}}),g.set(this,{writable:!0,value:function(){-1!==n.player.playDirection&&0!==n.player.currentFrame&&"pauseHold"!==n.actions[n.interactionIdx].transition&&"pauseHold"!==n.actions[0].type||(n.player.setDirection(1),n.player.play())}}),E.set(this,{writable:!0,value:function(){"hold"===n.actions[n.interactionIdx].transition||"hold"===n.actions[0].type?(n.player.setDirection(-1),n.player.play()):"pauseHold"!==n.actions[n.interactionIdx].transition&&"pauseHold"!==n.actions[0].type||n.player.pause()}}),w.set(this,{writable:!0,value:function(){var e=n.actions[n.interactionIdx].state;"hover"!==e&&"click"!==e||(n.container.removeEventListener("click",i(n,c)),n.container.removeEventListener("mouseenter",i(n,c)))}}),b.set(this,{writable:!0,value:function(){var e=n.interactionIdx;i(n,w).call(n);var t=n.actions[n.interactionIdx].jumpTo;t?t>=0&&t<n.actions.length?(n.interactionIdx=t,i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx=0,n.player.goToAndStop(0,!0),i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx++,n.interactionIdx>=n.actions.length?n.actions[n.actions.length-1].reset?(n.interactionIdx=0,n.player.goToAndStop(0,!0),i(n,I).call(n,{ignorePath:!1})):(n.interactionIdx=n.actions.length-1,i(n,I).call(n,{ignorePath:!1})):i(n,I).call(n,{ignorePath:!1})),n.container.dispatchEvent(new CustomEvent("transition",{bubbles:!0,composed:!0,detail:{oldIndex:e,newIndex:n.interactionIdx}}))}}),k.set(this,{writable:!0,value:function(e){var t=n.actions[n.interactionIdx].frames;if(!t)return n.player.resetSegments(!0),void n.player.goToAndPlay(0,!0);"string"==typeof t?n.player.goToAndPlay(t,e):n.player.playSegments(t,e)}}),x.set(this,{writable:!0,value:function(){var t=n.actions[n.interactionIdx].path;if(!t)if("object"===e(n.enteredPlayer)&&"AnimationItem"===n.enteredPlayer.constructor.name){if(t=n.enteredPlayer,n.player===t)return void i(n,I).call(n,{ignorePath:!0})}else{var a=(t=n.loadedAnimation).substr(t.lastIndexOf("/")+1);if(a=a.substr(0,a.lastIndexOf(".json")),n.player.fileName===a)return void i(n,I).call(n,{ignorePath:!0})}var r=n.container.getBoundingClientRect(),s="width: "+r.width+"px !important; height: "+r.height+"px !important; background: "+n.container.style.background;if(n.container.setAttribute("style",s),"object"!==e(n.enteredPlayer)||"AnimationItem"!==n.enteredPlayer.constructor.name){if("string"==typeof n.enteredPlayer){var l=document.querySelector(n.enteredPlayer);l&&"LOTTIE-PLAYER"===l.nodeName&&(n.attachedListeners||(l.addEventListener("ready",(function(){n.container.style.width="",n.container.style.height=""})),l.addEventListener("load",(function(){n.player=l.getLottie(),i(n,I).call(n,{ignorePath:!0})})),n.attachedListeners=!0),l.load(t))}else n.enteredPlayer instanceof HTMLElement&&"LOTTIE-PLAYER"===n.enteredPlayer.nodeName&&(n.attachedListeners||(n.enteredPlayer.addEventListener("ready",(function(){n.container.style.width="",n.container.style.height=""})),n.enteredPlayer.addEventListener("load",(function(){n.player=n.enteredPlayer.getLottie(),i(n,I).call(n,{ignorePath:!0})})),n.attachedListeners=!0),n.enteredPlayer.load(t));if(!n.player)throw new Error("".concat(o," Specified player is invalid."),n.enteredPlayer)}else{if(!window.lottie)throw new Error("".concat(o," A Lottie player is required."));n.stop(),n.player.destroy(),n.container.innerHTML="","object"===e(t)&&"AnimationItem"===t.constructor.name?n.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,animationData:t.animationData,container:n.container}):n.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,path:t,container:n.container}),n.player.addEventListener("DOMLoaded",(function(){n.container.style.width="",n.container.style.height="",i(n,I).call(n,{ignorePath:!0})}))}n.clickCounter=0,n.playCounter=0}}),I.set(this,{writable:!0,value:function(e){var t=e.ignorePath,a=n.actions[n.interactionIdx].state,r=n.actions[n.interactionIdx].transition,o=n.actions[n.interactionIdx].path,s=n.stateHandler.get(a),l=n.transitionHandler.get(r),c=n.actions[n.interactionIdx].speed?n.actions[n.interactionIdx].speed:1,p=n.actions[n.interactionIdx].delay?n.actions[n.interactionIdx].delay:0;t||!(o||n.actions[n.actions.length-1].reset&&0===n.interactionIdx)?setTimeout((function(){s?s.call():"none"===a&&(n.player.loop=!1,n.player.autoplay=!1),l&&l.call(),n.player.autoplay&&(n.player.resetSegments(!0),i(n,k).call(n,!0)),n.player.setSpeed(c)}),p):i(n,x).call(n)}}),P.set(this,{writable:!0,value:function(e,t){if(-1!==e&&-1!==t){var a=n.getContainerCursorPosition(e,t);e=a.x,t=a.y}var i=n.actions.find((function(n){var a=n.position;if(a){if(Array.isArray(a.x)&&Array.isArray(a.y))return e>=a.x[0]&&e<=a.x[1]&&t>=a.y[0]&&t<=a.y[1];if(!Number.isNaN(a.x)&&!Number.isNaN(a.y))return e===a.x&&t===a.y}return!1}));if(i)if("seek"===i.type||"seek"===i.transition){var r=(e-i.position.x[0])/(i.position.x[1]-i.position.x[0]),o=(t-i.position.y[0])/(i.position.y[1]-i.position.y[0]);n.player.playSegments(i.frames,!0),i.position.y[0]<0&&i.position.y[1]>1?n.player.goToAndStop(Math.floor(r*n.player.totalFrames),!0):n.player.goToAndStop(Math.ceil((r+o)/2*n.player.totalFrames),!0)}else"loop"===i.type?n.player.playSegments(i.frames,!0):"play"===i.type?(!0===n.player.isPaused&&n.player.resetSegments(),n.player.playSegments(i.frames)):"stop"===i.type&&(n.player.resetSegments(!0),n.player.goToAndStop(i.frames[0],!0))}}),S.set(this,{writable:!0,value:function(){var e=n.getContainerVisibility(),t=n.actions.find((function(t){var n=t.visibility;return e>=n[0]&&e<=n[1]}));if(t)if("seek"===t.type){var a=t.frames[0],i=2==t.frames.length?t.frames[1]:n.player.totalFrames-1;null!==n.assignedSegment&&(n.player.resetSegments(!0),n.assignedSegment=null),n.player.goToAndStop(a+Math.round((e-t.visibility[0])/(t.visibility[1]-t.visibility[0])*(i-a)),!0)}else"loop"===t.type?(n.player.loop=!0,(null===n.assignedSegment||n.assignedSegment!==t.frames||!0===n.player.isPaused)&&(n.player.playSegments(t.frames,!0),n.assignedSegment=t.frames)):"play"===t.type?n.scrolledAndPlayed||(n.scrolledAndPlayed=!0,n.player.resetSegments(!0),n.player.play()):"stop"===t.type&&n.player.goToAndStop(t.frames[0],!0)}}),this.enteredPlayer=H,"object"!==e(H)||"AnimationItem"!==H.constructor.name){if("string"==typeof H){var W=document.querySelector(H);W&&"LOTTIE-PLAYER"===W.nodeName&&(H=W.getLottie())}else H instanceof HTMLElement&&"LOTTIE-PLAYER"===H.nodeName&&(H=H.getLottie());if(!H){var F=o+"Specified player:"+H+" is invalid.";throw new Error(F)}}"string"==typeof C&&(C=document.querySelector(C)),C||(C=H.wrapper),this.player=H,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=C,this.mode=T,this.actions=M,this.options=O,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map}var A,M,C;return A=s,(M=[{key:"getContainerVisibility",value:function(){var e=this.container.getBoundingClientRect(),t=e.top,n=e.height;return(window.innerHeight-t)/(window.innerHeight+n)}},{key:"getContainerCursorPosition",value:function(e,t){var n=this.container.getBoundingClientRect(),a=n.top;return{x:(e-n.left)/n.width,y:(t-a)/n.height}}},{key:"start",value:function(){var e=this;"scroll"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.player.stop(),window.addEventListener("scroll",i(e,S))})):"cursor"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.actions&&1===e.actions.length?"click"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",i(e,d))):"hover"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("mouseenter",i(e,d)),e.container.addEventListener("touchstart",i(e,d),{passive:!0})):"toggle"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",i(e,p))):"hold"===e.actions[0].type||"pauseHold"===e.actions[0].type?(e.container.addEventListener("mouseenter",i(e,g)),e.container.addEventListener("mouseleave",i(e,E)),e.container.addEventListener("touchstart",i(e,g),{passive:!0}),e.container.addEventListener("touchend",i(e,E),{passive:!0})):"seek"===e.actions[0].type&&(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",i(e,y)),e.container.addEventListener("touchmove",i(e,u),{passive:!1}),e.container.addEventListener("mouseout",i(e,v))):(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",i(e,y)),e.container.addEventListener("mouseleave",i(e,v)),i(e,P).call(e,-1,-1))})):"chain"===this.mode&&(this.player.isLoaded?(i(e,l).call(e),e.player.loop=!1,e.player.stop(),i(e,I).call(e,{ignorePath:!1})):this.player.addEventListener("DOMLoaded",(function(){i(e,l).call(e),e.player.loop=!1,e.player.stop(),i(e,I).call(e,{ignorePath:!1})})))}},{key:"redefineOptions",value:function(t){var n=t.actions,i=t.container,r=t.mode,s=t.player,l=a(t,["actions","container","mode","player"]);if(this.stop(),this.player.stop(),this.enteredPlayer=s,"object"!==e(s)||"AnimationItem"!==s.constructor.name){if("string"==typeof s){var c=document.querySelector(s);c&&"LOTTIE-PLAYER"===c.nodeName&&(s=c.getLottie())}else s instanceof HTMLElement&&"LOTTIE-PLAYER"===s.nodeName&&(s=s.getLottie());if(!s)throw new Error(o+"Specified player:"+s+" is invalid.",s)}"string"==typeof i&&(i=document.querySelector(i)),i||(i=s.wrapper),this.player=s,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=i,this.mode=r,this.actions=n,this.options=l,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map,this.start()}},{key:"stop",value:function(){"scroll"===this.mode&&window.removeEventListener("scroll",i(this,S)),"cursor"===this.mode&&(this.container.removeEventListener("click",i(this,d)),this.container.removeEventListener("click",i(this,p)),this.container.removeEventListener("mouseenter",i(this,d)),this.container.removeEventListener("touchstart",i(this,d)),this.container.removeEventListener("touchmove",i(this,u)),this.container.removeEventListener("mousemove",i(this,y)),this.container.removeEventListener("mouseleave",i(this,v)),this.container.removeEventListener("touchstart",i(this,g)),this.container.removeEventListener("touchend",i(this,E))),"chain"===this.mode&&(this.container.removeEventListener("click",i(this,d)),this.container.removeEventListener("click",i(this,c)),this.container.removeEventListener("mouseenter",i(this,d)),this.container.removeEventListener("touchstart",i(this,d)),this.container.removeEventListener("touchmove",i(this,u)),this.container.removeEventListener("mouseenter",i(this,c)),this.container.removeEventListener("touchstart",i(this,c)),this.container.removeEventListener("mouseenter",i(this,g)),this.container.removeEventListener("touchstart",i(this,g)),this.container.removeEventListener("mouseleave",i(this,E)),this.container.removeEventListener("mousemove",i(this,y)),this.container.removeEventListener("mouseout",i(this,v)),this.container.removeEventListener("touchend",i(this,E)),this.player.removeEventListener("loopComplete",i(this,h)),this.player.removeEventListener("complete",i(this,h)),this.player.removeEventListener("enterFrame",i(this,f)),this.player.removeEventListener("enterFrame",i(this,L)))}}])&&n(A.prototype,M),C&&n(A,C),s}(),l=new WeakMap,c=new WeakMap,p=new WeakMap,d=new WeakMap,y=new WeakMap,u=new WeakMap,v=new WeakMap,h=new WeakMap,m=new WeakMap,f=new WeakMap,L=new WeakMap,g=new WeakMap,E=new WeakMap,w=new WeakMap,b=new WeakMap,k=new WeakMap,x=new WeakMap,I=new WeakMap,P=new WeakMap,S=new WeakMap,A=function(e){var t=new s(e);return t.start(),t};export default A;export{s as LottieInteractivity,A as create}; | ||
//# sourceMappingURL=lottie-interactivity.es.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).LottieInteractivity={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function i(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function r(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var o={player:"lottie-player"},s="[lottieInteractivity]:",l=function(){function e(){var a=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o,M=l.actions,C=l.container,T=l.mode,H=l.player,O=i(l,["actions","container","mode","player"]);if(n(this,e),c.set(this,{writable:!0,value:function(){if(a.player){var e=function(){a.player.addEventListener("enterFrame",r(a,L)),a.container.addEventListener("mouseenter",r(a,E)),a.container.addEventListener("mouseleave",r(a,w))};a.stateHandler.set("loop",(function(){a.actions[a.interactionIdx].loop?a.player.loop=parseInt(a.actions[a.interactionIdx].loop)-1:a.player.loop=!0,a.player.autoplay=!0})),a.stateHandler.set("autoplay",(function(){a.player.loop=!1,a.player.autoplay=!0})),a.stateHandler.set("click",(function(){a.player.loop=!1,a.player.autoplay=!1,a.container.addEventListener("click",r(a,p))})),a.stateHandler.set("hover",(function(){a.player.loop=!1,a.player.autoplay=!1,a.container.addEventListener("mouseenter",r(a,p))})),a.transitionHandler.set("click",(function(){a.container.addEventListener("click",r(a,y))})),a.transitionHandler.set("hover",(function(){a.container.addEventListener("mouseenter",r(a,y))})),a.transitionHandler.set("hold",e),a.transitionHandler.set("pauseHold",e),a.transitionHandler.set("repeat",(function(){a.player.loop=!0,a.player.autoplay=!0;a.player.addEventListener("loopComplete",(function e(){r(a,f).call(a,{handler:e})}))})),a.transitionHandler.set("onComplete",(function(){"loop"===a.actions[a.interactionIdx].state?a.player.addEventListener("loopComplete",r(a,h)):a.player.addEventListener("complete",r(a,h))})),a.transitionHandler.set("seek",(function(){a.player.stop(),a.player.addEventListener("enterFrame",r(a,g)),a.container.addEventListener("mousemove",r(a,u)),a.container.addEventListener("touchmove",r(a,v)),a.container.addEventListener("mouseout",r(a,m))}))}}}),p.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].forceFlag;e||!0!==a.player.isPaused?e&&r(a,x).call(a,!0):r(a,x).call(a,!0)}}),d.set(this,{writable:!0,value:function(){0===a.clickCounter?(a.player.play(),a.clickCounter++):(a.clickCounter++,a.player.setDirection(-1*a.player.playDirection),a.player.play())}}),y.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].forceFlag;if("chain"===a.mode){if(a.actions[a.interactionIdx].count){var t=parseInt(a.actions[a.interactionIdx].count);if(a.clickCounter<t-1)return void(a.clickCounter+=1)}return a.clickCounter=0,a.container.removeEventListener("click",r(a,y)),a.container.removeEventListener("mouseenter",r(a,y)),void r(a,I).call(a)}e||!0!==a.player.isPaused?e&&a.player.goToAndPlay(0,!0):a.player.goToAndPlay(0,!0)}}),u.set(this,{writable:!0,value:function(e){r(a,S).call(a,e.clientX,e.clientY)}}),v.set(this,{writable:!0,value:function(e){e.cancelable&&e.preventDefault(),r(a,S).call(a,e.touches[0].clientX,e.touches[0].clientY)}}),m.set(this,{writable:!0,value:function(){r(a,S).call(a,-1,-1)}}),h.set(this,{writable:!0,value:function(){"loop"===a.actions[a.interactionIdx].state?a.player.removeEventListener("loopComplete",r(a,h)):a.player.removeEventListener("complete",r(a,h)),r(a,I).call(a)}}),f.set(this,{writable:!0,value:function(e){var t=e.handler,n=1;a.actions[a.interactionIdx].repeat&&(n=a.actions[a.interactionIdx].repeat),a.playCounter>=n-1?(a.playCounter=0,a.player.removeEventListener("loopComplete",t),a.player.loop=!1,a.player.autoplay=!1,r(a,I).call(a)):a.playCounter+=1}}),g.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].frames;e&&a.player.currentFrame>=parseInt(e[1])-1&&(a.player.removeEventListener("enterFrame",r(a,g)),a.container.removeEventListener("mousemove",r(a,u)),a.container.removeEventListener("mouseout",r(a,m)),setTimeout(r(a,I),0))}}),L.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].frames;(e&&a.player.currentFrame>=e[1]||a.player.currentFrame>=a.player.totalFrames-1)&&(a.player.removeEventListener("enterFrame",r(a,L)),a.container.removeEventListener("mouseenter",r(a,E)),a.container.removeEventListener("mouseleave",r(a,w)),a.player.pause(),r(a,I).call(a))}}),E.set(this,{writable:!0,value:function(){-1!==a.player.playDirection&&0!==a.player.currentFrame&&"pauseHold"!==a.actions[a.interactionIdx].transition&&"pauseHold"!==a.actions[0].type||(a.player.setDirection(1),a.player.play())}}),w.set(this,{writable:!0,value:function(){"hold"===a.actions[a.interactionIdx].transition||"hold"===a.actions[0].type?(a.player.setDirection(-1),a.player.play()):"pauseHold"!==a.actions[a.interactionIdx].transition&&"pauseHold"!==a.actions[0].type||a.player.pause()}}),b.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].state;"hover"!==e&&"click"!==e||(a.container.removeEventListener("click",r(a,p)),a.container.removeEventListener("mouseenter",r(a,p)))}}),I.set(this,{writable:!0,value:function(){var e=a.interactionIdx;r(a,b).call(a);var t=a.actions[a.interactionIdx].jumpTo;t?t>=0&&t<a.actions.length?(a.interactionIdx=t,r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx=0,a.player.goToAndStop(0,!0),r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx++,a.interactionIdx>=a.actions.length?a.actions[a.actions.length-1].reset?(a.interactionIdx=0,a.player.goToAndStop(0,!0),r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx=a.actions.length-1,r(a,P).call(a,{ignorePath:!1})):r(a,P).call(a,{ignorePath:!1})),a.container.dispatchEvent(new CustomEvent("transition",{bubbles:!0,composed:!0,detail:{oldIndex:e,newIndex:a.interactionIdx}}))}}),x.set(this,{writable:!0,value:function(e){var t=a.actions[a.interactionIdx].frames;if(!t)return a.player.resetSegments(!0),void a.player.goToAndPlay(0,!0);"string"==typeof t?a.player.goToAndPlay(t,e):a.player.playSegments(t,e)}}),k.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].path;if(!e)if("object"===t(a.enteredPlayer)&&"AnimationItem"===a.enteredPlayer.constructor.name){if(e=a.enteredPlayer,a.player===e)return void r(a,P).call(a,{ignorePath:!0})}else{var n=(e=a.loadedAnimation).substr(e.lastIndexOf("/")+1);if(n=n.substr(0,n.lastIndexOf(".json")),a.player.fileName===n)return void r(a,P).call(a,{ignorePath:!0})}var i=a.container.getBoundingClientRect(),o="width: "+i.width+"px !important; height: "+i.height+"px !important; background: "+a.container.style.background;if(a.container.setAttribute("style",o),"object"!==t(a.enteredPlayer)||"AnimationItem"!==a.enteredPlayer.constructor.name){if("string"==typeof a.enteredPlayer){var l=document.querySelector(a.enteredPlayer);l&&"LOTTIE-PLAYER"===l.nodeName&&(a.attachedListeners||(l.addEventListener("ready",(function(){a.container.style.width="",a.container.style.height=""})),l.addEventListener("load",(function(){a.player=l.getLottie(),r(a,P).call(a,{ignorePath:!0})})),a.attachedListeners=!0),l.load(e))}else a.enteredPlayer instanceof HTMLElement&&"LOTTIE-PLAYER"===a.enteredPlayer.nodeName&&(a.attachedListeners||(a.enteredPlayer.addEventListener("ready",(function(){a.container.style.width="",a.container.style.height=""})),a.enteredPlayer.addEventListener("load",(function(){a.player=a.enteredPlayer.getLottie(),r(a,P).call(a,{ignorePath:!0})})),a.attachedListeners=!0),a.enteredPlayer.load(e));if(!a.player)throw new Error("".concat(s," Specified player is invalid."),a.enteredPlayer)}else{if(!window.lottie)throw new Error("".concat(s," A Lottie player is required."));a.stop(),a.player.destroy(),a.container.innerHTML="","object"===t(e)&&"AnimationItem"===e.constructor.name?a.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,animationData:e.animationData,container:a.container}):a.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,path:e,container:a.container}),a.player.addEventListener("DOMLoaded",(function(){a.container.style.width="",a.container.style.height="",r(a,P).call(a,{ignorePath:!0})}))}a.clickCounter=0,a.playCounter=0}}),P.set(this,{writable:!0,value:function(e){var t=e.ignorePath,n=a.actions[a.interactionIdx].state,i=a.actions[a.interactionIdx].transition,o=a.actions[a.interactionIdx].path,s=a.stateHandler.get(n),l=a.transitionHandler.get(i),c=a.actions[a.interactionIdx].speed?a.actions[a.interactionIdx].speed:1,p=a.actions[a.interactionIdx].delay?a.actions[a.interactionIdx].delay:0;t||!(o||a.actions[a.actions.length-1].reset&&0===a.interactionIdx)?setTimeout((function(){s?s.call():"none"===n&&(a.player.loop=!1,a.player.autoplay=!1),l&&l.call(),a.player.autoplay&&(a.player.resetSegments(!0),r(a,x).call(a,!0)),a.player.setSpeed(c)}),p):r(a,k).call(a)}}),S.set(this,{writable:!0,value:function(e,t){if(-1!==e&&-1!==t){var n=a.getContainerCursorPosition(e,t);e=n.x,t=n.y}var i=a.actions.find((function(n){var a=n.position;if(a){if(Array.isArray(a.x)&&Array.isArray(a.y))return e>=a.x[0]&&e<=a.x[1]&&t>=a.y[0]&&t<=a.y[1];if(!Number.isNaN(a.x)&&!Number.isNaN(a.y))return e===a.x&&t===a.y}return!1}));if(i)if("seek"===i.type||"seek"===i.transition){var r=(e-i.position.x[0])/(i.position.x[1]-i.position.x[0]),o=(t-i.position.y[0])/(i.position.y[1]-i.position.y[0]);a.player.playSegments(i.frames,!0),i.position.y[0]<0&&i.position.y[1]>1?a.player.goToAndStop(Math.floor(r*a.player.totalFrames),!0):a.player.goToAndStop(Math.ceil((r+o)/2*a.player.totalFrames),!0)}else"loop"===i.type?a.player.playSegments(i.frames,!0):"play"===i.type?(!0===a.player.isPaused&&a.player.resetSegments(),a.player.playSegments(i.frames)):"stop"===i.type&&(a.player.resetSegments(!0),a.player.goToAndStop(i.frames[0],!0))}}),A.set(this,{writable:!0,value:function(){var e=a.getContainerVisibility(),t=a.actions.find((function(t){var n=t.visibility;return e>=n[0]&&e<=n[1]}));if(t)if("seek"===t.type){var n=t.frames[0],i=2==t.frames.length?t.frames[1]:a.player.totalFrames-1;null!==a.assignedSegment&&(a.player.resetSegments(!0),a.assignedSegment=null),a.player.goToAndStop(n+Math.round((e-t.visibility[0])/(t.visibility[1]-t.visibility[0])*(i-n)),!0)}else"loop"===t.type?(a.player.loop=!0,(null===a.assignedSegment||a.assignedSegment!==t.frames||!0===a.player.isPaused)&&(a.player.playSegments(t.frames,!0),a.assignedSegment=t.frames)):"play"===t.type?a.scrolledAndPlayed||(a.scrolledAndPlayed=!0,a.player.resetSegments(!0),a.player.play()):"stop"===t.type&&a.player.goToAndStop(t.frames[0],!0)}}),this.enteredPlayer=H,"object"!==t(H)||"AnimationItem"!==H.constructor.name){if("string"==typeof H){var W=document.querySelector(H);W&&"LOTTIE-PLAYER"===W.nodeName&&(H=W.getLottie())}else H instanceof HTMLElement&&"LOTTIE-PLAYER"===H.nodeName&&(H=H.getLottie());if(!H){var j=s+"Specified player:"+H+" is invalid.";throw new Error(j)}}"string"==typeof C&&(C=document.querySelector(C)),C||(C=H.wrapper),this.player=H,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=C,this.mode=T,this.actions=M,this.options=O,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map}var l,M,C;return l=e,(M=[{key:"getContainerVisibility",value:function(){var e=this.container.getBoundingClientRect(),t=e.top,n=e.height;return(window.innerHeight-t)/(window.innerHeight+n)}},{key:"getContainerCursorPosition",value:function(e,t){var n=this.container.getBoundingClientRect(),a=n.top;return{x:(e-n.left)/n.width,y:(t-a)/n.height}}},{key:"start",value:function(){var e=this;"scroll"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.player.stop(),window.addEventListener("scroll",r(e,A))})):"cursor"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.actions&&1===e.actions.length?"click"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",r(e,y))):"hover"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("mouseenter",r(e,y))):"toggle"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",r(e,d))):"hold"===e.actions[0].type||"pauseHold"===e.actions[0].type?(e.container.addEventListener("mouseenter",r(e,E)),e.container.addEventListener("mouseleave",r(e,w))):"seek"===e.actions[0].type&&(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",r(e,u)),e.container.addEventListener("touchmove",r(e,v)),e.container.addEventListener("mouseout",r(e,m))):(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",r(e,u)),e.container.addEventListener("mouseleave",r(e,m)),r(e,S).call(e,-1,-1))})):"chain"===this.mode&&(this.player.isLoaded?(r(e,c).call(e),e.player.loop=!1,e.player.stop(),r(e,P).call(e,{ignorePath:!1})):this.player.addEventListener("DOMLoaded",(function(){r(e,c).call(e),e.player.loop=!1,e.player.stop(),r(e,P).call(e,{ignorePath:!1})})))}},{key:"redefineOptions",value:function(e){var n=e.actions,a=e.container,r=e.mode,o=e.player,l=i(e,["actions","container","mode","player"]);if(this.stop(),this.player.stop(),this.enteredPlayer=o,"object"!==t(o)||"AnimationItem"!==o.constructor.name){if("string"==typeof o){var c=document.querySelector(o);c&&"LOTTIE-PLAYER"===c.nodeName&&(o=c.getLottie())}else o instanceof HTMLElement&&"LOTTIE-PLAYER"===o.nodeName&&(o=o.getLottie());if(!o)throw new Error(s+"Specified player:"+o+" is invalid.",o)}"string"==typeof a&&(a=document.querySelector(a)),a||(a=o.wrapper),this.player=o,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=a,this.mode=r,this.actions=n,this.options=l,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map,this.start()}},{key:"stop",value:function(){"scroll"===this.mode&&window.removeEventListener("scroll",r(this,A)),"cursor"===this.mode&&(this.container.removeEventListener("click",r(this,y)),this.container.removeEventListener("click",r(this,d)),this.container.removeEventListener("mouseenter",r(this,y)),this.container.addEventListener("touchmove",r(this,v)),this.container.removeEventListener("mousemove",r(this,u)),this.container.removeEventListener("mouseleave",r(this,m))),"chain"===this.mode&&(this.container.removeEventListener("click",r(this,y)),this.container.removeEventListener("click",r(this,p)),this.container.removeEventListener("mouseenter",r(this,y)),this.container.removeEventListener("touchmove",r(this,v)),this.container.removeEventListener("mouseenter",r(this,p)),this.container.removeEventListener("mouseenter",r(this,E)),this.container.removeEventListener("mouseleave",r(this,w)),this.container.removeEventListener("mousemove",r(this,u)),this.container.removeEventListener("mouseout",r(this,m)),this.player.removeEventListener("loopComplete",r(this,h)),this.player.removeEventListener("complete",r(this,h)),this.player.removeEventListener("enterFrame",r(this,g)),this.player.removeEventListener("enterFrame",r(this,L)))}}])&&a(l.prototype,M),C&&a(l,C),e}(),c=new WeakMap,p=new WeakMap,d=new WeakMap,y=new WeakMap,u=new WeakMap,v=new WeakMap,m=new WeakMap,h=new WeakMap,f=new WeakMap,g=new WeakMap,L=new WeakMap,E=new WeakMap,w=new WeakMap,b=new WeakMap,I=new WeakMap,x=new WeakMap,k=new WeakMap,P=new WeakMap,S=new WeakMap,A=new WeakMap,M=function(e){var t=new l(e);return t.start(),t};e.LottieInteractivity=l,e.create=M,e.default=M,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).LottieInteractivity={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function i(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function r(e,t){var n=t.get(e);if(!n)throw new TypeError("attempted to get private field on non-instance");return n.get?n.get.call(e):n.value}var o={player:"lottie-player"},s="[lottieInteractivity]:",l=function(){function e(){var a=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o,M=l.actions,C=l.container,T=l.mode,H=l.player,O=i(l,["actions","container","mode","player"]);if(n(this,e),c.set(this,{writable:!0,value:function(){if(a.player){var e=function(){a.player.addEventListener("enterFrame",r(a,g)),a.container.addEventListener("mouseenter",r(a,E)),a.container.addEventListener("mouseleave",r(a,w)),a.container.addEventListener("touchstart",r(a,E),{passive:!0}),a.container.addEventListener("touchend",r(a,w),{passive:!0})};a.stateHandler.set("loop",(function(){a.actions[a.interactionIdx].loop?a.player.loop=parseInt(a.actions[a.interactionIdx].loop)-1:a.player.loop=!0,a.player.autoplay=!0})),a.stateHandler.set("autoplay",(function(){a.player.loop=!1,a.player.autoplay=!0})),a.stateHandler.set("click",(function(){a.player.loop=!1,a.player.autoplay=!1,a.container.addEventListener("click",r(a,p))})),a.stateHandler.set("hover",(function(){a.player.loop=!1,a.player.autoplay=!1,a.container.addEventListener("mouseenter",r(a,p)),a.container.addEventListener("touchstart",r(a,p),{passive:!0})})),a.transitionHandler.set("click",(function(){a.container.addEventListener("click",r(a,y))})),a.transitionHandler.set("hover",(function(){a.container.addEventListener("mouseenter",r(a,y)),a.container.addEventListener("touchstart",r(a,y),{passive:!0})})),a.transitionHandler.set("hold",e),a.transitionHandler.set("pauseHold",e),a.transitionHandler.set("repeat",(function(){a.player.loop=!0,a.player.autoplay=!0;a.player.addEventListener("loopComplete",(function e(){r(a,f).call(a,{handler:e})}))})),a.transitionHandler.set("onComplete",(function(){"loop"===a.actions[a.interactionIdx].state?a.player.addEventListener("loopComplete",r(a,m)):a.player.addEventListener("complete",r(a,m))})),a.transitionHandler.set("seek",(function(){a.player.stop(),a.player.addEventListener("enterFrame",r(a,L)),a.container.addEventListener("mousemove",r(a,u)),a.container.addEventListener("touchmove",r(a,v),{passive:!1}),a.container.addEventListener("mouseout",r(a,h))}))}}}),p.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].forceFlag;e||!0!==a.player.isPaused?e&&r(a,x).call(a,!0):r(a,x).call(a,!0)}}),d.set(this,{writable:!0,value:function(){0===a.clickCounter?(a.player.play(),a.clickCounter++):(a.clickCounter++,a.player.setDirection(-1*a.player.playDirection),a.player.play())}}),y.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].forceFlag;if("chain"===a.mode){if(a.actions[a.interactionIdx].count){var t=parseInt(a.actions[a.interactionIdx].count);if(a.clickCounter<t-1)return void(a.clickCounter+=1)}return a.clickCounter=0,a.container.removeEventListener("click",r(a,y)),a.container.removeEventListener("mouseenter",r(a,y)),void r(a,I).call(a)}e||!0!==a.player.isPaused?e&&a.player.goToAndPlay(0,!0):a.player.goToAndPlay(0,!0)}}),u.set(this,{writable:!0,value:function(e){r(a,S).call(a,e.clientX,e.clientY)}}),v.set(this,{writable:!0,value:function(e){e.cancelable&&e.preventDefault(),r(a,S).call(a,e.touches[0].clientX,e.touches[0].clientY)}}),h.set(this,{writable:!0,value:function(){r(a,S).call(a,-1,-1)}}),m.set(this,{writable:!0,value:function(){"loop"===a.actions[a.interactionIdx].state?a.player.removeEventListener("loopComplete",r(a,m)):a.player.removeEventListener("complete",r(a,m)),r(a,I).call(a)}}),f.set(this,{writable:!0,value:function(e){var t=e.handler,n=1;a.actions[a.interactionIdx].repeat&&(n=a.actions[a.interactionIdx].repeat),a.playCounter>=n-1?(a.playCounter=0,a.player.removeEventListener("loopComplete",t),a.player.loop=!1,a.player.autoplay=!1,r(a,I).call(a)):a.playCounter+=1}}),L.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].frames;e&&a.player.currentFrame>=parseInt(e[1])-1&&(a.player.removeEventListener("enterFrame",r(a,L)),a.container.removeEventListener("mousemove",r(a,u)),a.container.removeEventListener("mouseout",r(a,h)),setTimeout(r(a,I),0))}}),g.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].frames;(e&&a.player.currentFrame>=e[1]||a.player.currentFrame>=a.player.totalFrames-1)&&(a.player.removeEventListener("enterFrame",r(a,g)),a.container.removeEventListener("mouseenter",r(a,E)),a.container.removeEventListener("mouseleave",r(a,w)),a.player.pause(),r(a,I).call(a))}}),E.set(this,{writable:!0,value:function(){-1!==a.player.playDirection&&0!==a.player.currentFrame&&"pauseHold"!==a.actions[a.interactionIdx].transition&&"pauseHold"!==a.actions[0].type||(a.player.setDirection(1),a.player.play())}}),w.set(this,{writable:!0,value:function(){"hold"===a.actions[a.interactionIdx].transition||"hold"===a.actions[0].type?(a.player.setDirection(-1),a.player.play()):"pauseHold"!==a.actions[a.interactionIdx].transition&&"pauseHold"!==a.actions[0].type||a.player.pause()}}),b.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].state;"hover"!==e&&"click"!==e||(a.container.removeEventListener("click",r(a,p)),a.container.removeEventListener("mouseenter",r(a,p)))}}),I.set(this,{writable:!0,value:function(){var e=a.interactionIdx;r(a,b).call(a);var t=a.actions[a.interactionIdx].jumpTo;t?t>=0&&t<a.actions.length?(a.interactionIdx=t,r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx=0,a.player.goToAndStop(0,!0),r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx++,a.interactionIdx>=a.actions.length?a.actions[a.actions.length-1].reset?(a.interactionIdx=0,a.player.goToAndStop(0,!0),r(a,P).call(a,{ignorePath:!1})):(a.interactionIdx=a.actions.length-1,r(a,P).call(a,{ignorePath:!1})):r(a,P).call(a,{ignorePath:!1})),a.container.dispatchEvent(new CustomEvent("transition",{bubbles:!0,composed:!0,detail:{oldIndex:e,newIndex:a.interactionIdx}}))}}),x.set(this,{writable:!0,value:function(e){var t=a.actions[a.interactionIdx].frames;if(!t)return a.player.resetSegments(!0),void a.player.goToAndPlay(0,!0);"string"==typeof t?a.player.goToAndPlay(t,e):a.player.playSegments(t,e)}}),k.set(this,{writable:!0,value:function(){var e=a.actions[a.interactionIdx].path;if(!e)if("object"===t(a.enteredPlayer)&&"AnimationItem"===a.enteredPlayer.constructor.name){if(e=a.enteredPlayer,a.player===e)return void r(a,P).call(a,{ignorePath:!0})}else{var n=(e=a.loadedAnimation).substr(e.lastIndexOf("/")+1);if(n=n.substr(0,n.lastIndexOf(".json")),a.player.fileName===n)return void r(a,P).call(a,{ignorePath:!0})}var i=a.container.getBoundingClientRect(),o="width: "+i.width+"px !important; height: "+i.height+"px !important; background: "+a.container.style.background;if(a.container.setAttribute("style",o),"object"!==t(a.enteredPlayer)||"AnimationItem"!==a.enteredPlayer.constructor.name){if("string"==typeof a.enteredPlayer){var l=document.querySelector(a.enteredPlayer);l&&"LOTTIE-PLAYER"===l.nodeName&&(a.attachedListeners||(l.addEventListener("ready",(function(){a.container.style.width="",a.container.style.height=""})),l.addEventListener("load",(function(){a.player=l.getLottie(),r(a,P).call(a,{ignorePath:!0})})),a.attachedListeners=!0),l.load(e))}else a.enteredPlayer instanceof HTMLElement&&"LOTTIE-PLAYER"===a.enteredPlayer.nodeName&&(a.attachedListeners||(a.enteredPlayer.addEventListener("ready",(function(){a.container.style.width="",a.container.style.height=""})),a.enteredPlayer.addEventListener("load",(function(){a.player=a.enteredPlayer.getLottie(),r(a,P).call(a,{ignorePath:!0})})),a.attachedListeners=!0),a.enteredPlayer.load(e));if(!a.player)throw new Error("".concat(s," Specified player is invalid."),a.enteredPlayer)}else{if(!window.lottie)throw new Error("".concat(s," A Lottie player is required."));a.stop(),a.player.destroy(),a.container.innerHTML="","object"===t(e)&&"AnimationItem"===e.constructor.name?a.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,animationData:e.animationData,container:a.container}):a.player=window.lottie.loadAnimation({loop:!1,autoplay:!1,path:e,container:a.container}),a.player.addEventListener("DOMLoaded",(function(){a.container.style.width="",a.container.style.height="",r(a,P).call(a,{ignorePath:!0})}))}a.clickCounter=0,a.playCounter=0}}),P.set(this,{writable:!0,value:function(e){var t=e.ignorePath,n=a.actions[a.interactionIdx].state,i=a.actions[a.interactionIdx].transition,o=a.actions[a.interactionIdx].path,s=a.stateHandler.get(n),l=a.transitionHandler.get(i),c=a.actions[a.interactionIdx].speed?a.actions[a.interactionIdx].speed:1,p=a.actions[a.interactionIdx].delay?a.actions[a.interactionIdx].delay:0;t||!(o||a.actions[a.actions.length-1].reset&&0===a.interactionIdx)?setTimeout((function(){s?s.call():"none"===n&&(a.player.loop=!1,a.player.autoplay=!1),l&&l.call(),a.player.autoplay&&(a.player.resetSegments(!0),r(a,x).call(a,!0)),a.player.setSpeed(c)}),p):r(a,k).call(a)}}),S.set(this,{writable:!0,value:function(e,t){if(-1!==e&&-1!==t){var n=a.getContainerCursorPosition(e,t);e=n.x,t=n.y}var i=a.actions.find((function(n){var a=n.position;if(a){if(Array.isArray(a.x)&&Array.isArray(a.y))return e>=a.x[0]&&e<=a.x[1]&&t>=a.y[0]&&t<=a.y[1];if(!Number.isNaN(a.x)&&!Number.isNaN(a.y))return e===a.x&&t===a.y}return!1}));if(i)if("seek"===i.type||"seek"===i.transition){var r=(e-i.position.x[0])/(i.position.x[1]-i.position.x[0]),o=(t-i.position.y[0])/(i.position.y[1]-i.position.y[0]);a.player.playSegments(i.frames,!0),i.position.y[0]<0&&i.position.y[1]>1?a.player.goToAndStop(Math.floor(r*a.player.totalFrames),!0):a.player.goToAndStop(Math.ceil((r+o)/2*a.player.totalFrames),!0)}else"loop"===i.type?a.player.playSegments(i.frames,!0):"play"===i.type?(!0===a.player.isPaused&&a.player.resetSegments(),a.player.playSegments(i.frames)):"stop"===i.type&&(a.player.resetSegments(!0),a.player.goToAndStop(i.frames[0],!0))}}),A.set(this,{writable:!0,value:function(){var e=a.getContainerVisibility(),t=a.actions.find((function(t){var n=t.visibility;return e>=n[0]&&e<=n[1]}));if(t)if("seek"===t.type){var n=t.frames[0],i=2==t.frames.length?t.frames[1]:a.player.totalFrames-1;null!==a.assignedSegment&&(a.player.resetSegments(!0),a.assignedSegment=null),a.player.goToAndStop(n+Math.round((e-t.visibility[0])/(t.visibility[1]-t.visibility[0])*(i-n)),!0)}else"loop"===t.type?(a.player.loop=!0,(null===a.assignedSegment||a.assignedSegment!==t.frames||!0===a.player.isPaused)&&(a.player.playSegments(t.frames,!0),a.assignedSegment=t.frames)):"play"===t.type?a.scrolledAndPlayed||(a.scrolledAndPlayed=!0,a.player.resetSegments(!0),a.player.play()):"stop"===t.type&&a.player.goToAndStop(t.frames[0],!0)}}),this.enteredPlayer=H,"object"!==t(H)||"AnimationItem"!==H.constructor.name){if("string"==typeof H){var W=document.querySelector(H);W&&"LOTTIE-PLAYER"===W.nodeName&&(H=W.getLottie())}else H instanceof HTMLElement&&"LOTTIE-PLAYER"===H.nodeName&&(H=H.getLottie());if(!H){var j=s+"Specified player:"+H+" is invalid.";throw new Error(j)}}"string"==typeof C&&(C=document.querySelector(C)),C||(C=H.wrapper),this.player=H,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=C,this.mode=T,this.actions=M,this.options=O,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map}var l,M,C;return l=e,(M=[{key:"getContainerVisibility",value:function(){var e=this.container.getBoundingClientRect(),t=e.top,n=e.height;return(window.innerHeight-t)/(window.innerHeight+n)}},{key:"getContainerCursorPosition",value:function(e,t){var n=this.container.getBoundingClientRect(),a=n.top;return{x:(e-n.left)/n.width,y:(t-a)/n.height}}},{key:"start",value:function(){var e=this;"scroll"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.player.stop(),window.addEventListener("scroll",r(e,A))})):"cursor"===this.mode?this.player.addEventListener("DOMLoaded",(function(){e.actions&&1===e.actions.length?"click"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",r(e,y))):"hover"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("mouseenter",r(e,y)),e.container.addEventListener("touchstart",r(e,y),{passive:!0})):"toggle"===e.actions[0].type?(e.player.loop=!1,e.player.stop(),e.container.addEventListener("click",r(e,d))):"hold"===e.actions[0].type||"pauseHold"===e.actions[0].type?(e.container.addEventListener("mouseenter",r(e,E)),e.container.addEventListener("mouseleave",r(e,w)),e.container.addEventListener("touchstart",r(e,E),{passive:!0}),e.container.addEventListener("touchend",r(e,w),{passive:!0})):"seek"===e.actions[0].type&&(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",r(e,u)),e.container.addEventListener("touchmove",r(e,v),{passive:!1}),e.container.addEventListener("mouseout",r(e,h))):(e.player.loop=!0,e.player.stop(),e.container.addEventListener("mousemove",r(e,u)),e.container.addEventListener("mouseleave",r(e,h)),r(e,S).call(e,-1,-1))})):"chain"===this.mode&&(this.player.isLoaded?(r(e,c).call(e),e.player.loop=!1,e.player.stop(),r(e,P).call(e,{ignorePath:!1})):this.player.addEventListener("DOMLoaded",(function(){r(e,c).call(e),e.player.loop=!1,e.player.stop(),r(e,P).call(e,{ignorePath:!1})})))}},{key:"redefineOptions",value:function(e){var n=e.actions,a=e.container,r=e.mode,o=e.player,l=i(e,["actions","container","mode","player"]);if(this.stop(),this.player.stop(),this.enteredPlayer=o,"object"!==t(o)||"AnimationItem"!==o.constructor.name){if("string"==typeof o){var c=document.querySelector(o);c&&"LOTTIE-PLAYER"===c.nodeName&&(o=c.getLottie())}else o instanceof HTMLElement&&"LOTTIE-PLAYER"===o.nodeName&&(o=o.getLottie());if(!o)throw new Error(s+"Specified player:"+o+" is invalid.",o)}"string"==typeof a&&(a=document.querySelector(a)),a||(a=o.wrapper),this.player=o,this.loadedAnimation=this.player.path+this.player.fileName+".json",this.attachedListeners=!1,this.container=a,this.mode=r,this.actions=n,this.options=l,this.assignedSegment=null,this.scrolledAndPlayed=!1,this.interactionIdx=0,this.clickCounter=0,this.playCounter=0,this.stateHandler=new Map,this.transitionHandler=new Map,this.start()}},{key:"stop",value:function(){"scroll"===this.mode&&window.removeEventListener("scroll",r(this,A)),"cursor"===this.mode&&(this.container.removeEventListener("click",r(this,y)),this.container.removeEventListener("click",r(this,d)),this.container.removeEventListener("mouseenter",r(this,y)),this.container.removeEventListener("touchstart",r(this,y)),this.container.removeEventListener("touchmove",r(this,v)),this.container.removeEventListener("mousemove",r(this,u)),this.container.removeEventListener("mouseleave",r(this,h)),this.container.removeEventListener("touchstart",r(this,E)),this.container.removeEventListener("touchend",r(this,w))),"chain"===this.mode&&(this.container.removeEventListener("click",r(this,y)),this.container.removeEventListener("click",r(this,p)),this.container.removeEventListener("mouseenter",r(this,y)),this.container.removeEventListener("touchstart",r(this,y)),this.container.removeEventListener("touchmove",r(this,v)),this.container.removeEventListener("mouseenter",r(this,p)),this.container.removeEventListener("touchstart",r(this,p)),this.container.removeEventListener("mouseenter",r(this,E)),this.container.removeEventListener("touchstart",r(this,E)),this.container.removeEventListener("mouseleave",r(this,w)),this.container.removeEventListener("mousemove",r(this,u)),this.container.removeEventListener("mouseout",r(this,h)),this.container.removeEventListener("touchend",r(this,w)),this.player.removeEventListener("loopComplete",r(this,m)),this.player.removeEventListener("complete",r(this,m)),this.player.removeEventListener("enterFrame",r(this,L)),this.player.removeEventListener("enterFrame",r(this,g)))}}])&&a(l.prototype,M),C&&a(l,C),e}(),c=new WeakMap,p=new WeakMap,d=new WeakMap,y=new WeakMap,u=new WeakMap,v=new WeakMap,h=new WeakMap,m=new WeakMap,f=new WeakMap,L=new WeakMap,g=new WeakMap,E=new WeakMap,w=new WeakMap,b=new WeakMap,I=new WeakMap,x=new WeakMap,k=new WeakMap,P=new WeakMap,S=new WeakMap,A=new WeakMap,M=function(e){var t=new l(e);return t.start(),t};e.LottieInteractivity=l,e.create=M,e.default=M,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=lottie-interactivity.min.js.map |
{ | ||
"name": "@lottiefiles/lottie-interactivity", | ||
"description": "This is a small effects and interactivity library written to be paired with the Lottie Web Player", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "./dist/lottie-interactivity.min.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
205486
269
2