lezzo.org/clippy/dist/index.js

3 lines
17 KiB
JavaScript
Raw Permalink Normal View History

2023-07-06 10:04:37 +01:00
var t=function(t){this._queue=[],this._onEmptyCallback=t};t.prototype.queue=function(t){this._queue.push(t),1!==this._queue.length||this._active||this._progressQueue()},t.prototype._progressQueue=function(){if(this._queue.length){var t=this._queue.shift();this._active=!0;var e=this.next.bind(this);t&&t(e)}else this._onEmptyCallback()},t.prototype.clear=function(){this._queue=[]},t.prototype.next=function(){this._active=!1,this._progressQueue()};var e=function(t,e,i){this._el=t,this._data=e.config,this._path=e.image,this._currentFrameIndex=0,this._currentFrame=void 0,this._exiting=!1,this._currentAnimation=void 0,this._endCallback=void 0,this._started=!1,this._sounds={},this.currentAnimationName=void 0,this.preloadSounds(i),this._overlays=[this._el];var n=this._el;this._setupElement(this._el);for(var o=1;o<this._data.overlayCount;o++){var r=document.createElement("div"),s=this._setupElement(r);n.append(s),this._overlays.push(s),n=s}};e.prototype._setupElement=function(t){var e=this._data.framesize;return t.style.display="none",t.style.width=e[0]+"px",t.style.height=e[1]+"px",t.style.background="url('"+this._path+"') no-repeat",t},e.prototype.animations=function(){var t=[],e=this._data.animations;for(var i in e)t.push(i);return t},e.prototype.preloadSounds=function(t){},e.prototype.hasAnimation=function(t){return!!this._data.animations[t]},e.prototype.exitAnimation=function(){this._exiting=!0},e.prototype.showAnimation=function(t,e){return this._exiting=!1,!!this.hasAnimation(t)&&(this._currentAnimation=this._data.animations[t],this.currentAnimationName=t,this._started||(this._step(),this._started=!0),this._currentFrameIndex=0,this._currentFrame=void 0,this._endCallback=e,!0)},e.prototype._draw=function(){var t=[];this._currentFrame&&(t=this._currentFrame.images||[]);for(var e=0;e<this._overlays.length;e++)if(e<t.length){var i=t[e],n=-i[0]+"px "+-i[1]+"px";this._overlays[e].style.backgroundPosition=n,this._overlays[e].style.display="block"}else this._overlays[e].style.display="none"},e.prototype._getNextAnimationFrame=function(){if(!this._currentAnimation)return 0;if(!this._currentFrame)return 0;var t=this._currentFrame,e=this._currentFrame.branching;if(this._exiting&&void 0!==t.exitBranch)return t.exitBranch;if(e)for(var i=100*Math.random(),n=0;n<e.branches.length;n++){var o=e.branches[n];if(i<=o.weight)return o.frameIndex;i-=o.weight}return this._currentFrameIndex+1},e.prototype._playSound=function(){var t,e=null===(t=this._currentFrame)||void 0===t?void 0:t.sound;if(e){var i=this._sounds[e];i&&i.play()}},e.prototype._atLastFrame=function(){return!!this._currentAnimation&&this._currentFrameIndex>=this._currentAnimation.frames.length-1},e.prototype._step=function(){if(this._currentAnimation){var t=Math.min(this._getNextAnimationFrame(),this._currentAnimation.frames.length-1),i=!this._currentFrame||this._currentFrameIndex!==t;this._currentFrameIndex=t,this._atLastFrame()&&this._currentAnimation.useExitBranching||(this._currentFrame=this._currentAnimation.frames[this._currentFrameIndex]),this._draw(),this._playSound(),this._loop=window.setTimeout(this._step.bind(this),this._currentFrame.duration),this._endCallback&&i&&this._atLastFrame()&&(this._currentAnimation.useExitBranching&&!this._exiting?this._endCallback(this.currentAnimationName,e.States.WAITING):this._endCallback(this.currentAnimationName,e.States.EXITED))}},e.prototype.pause=function(){window.clearTimeout(this._loop)},e.prototype.resume=function(){this._step()},e.States={WAITING:1,EXITED:0};var i=function(){var t=void 0!==window.pageXOffset,e="CSS1Compat"===(document.compatMode||"");return{scrollLeft:t?window.pageXOffset:e?document.documentElement.scrollLeft:document.body.scrollLeft,scrollTop:t?window.pageYOffset:e?document.documentElement.scrollTop:document.body.scrollTop}};function n(t){if(!t.getClientRects().length)return{top:0,left:0};var e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||{pageXOffset:0,pageYOffset:0};return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}}function o(t,e){if("inner"===e)return t.clientWidth;if("outer"===e)return t.
//# sourceMappingURL=index.js.map