-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.bundle.js
2 lines (2 loc) · 1.95 KB
/
demo.bundle.js
1
2
(()=>{"use strict";const e=function(){function e(e){var t,n,i,o,s,r;this.element=document.createElement("div");var l=Object.assign({r:255,g:0,b:0},null==e?void 0:e.color);Object.assign(this.element.style,{display:"none",width:null!==(n=null===(t=null==e?void 0:e.style)||void 0===t?void 0:t.width)&&void 0!==n?n:"15px",height:null!==(o=null===(i=null==e?void 0:e.style)||void 0===i?void 0:i.height)&&void 0!==o?o:"15px",borderRadius:"50%",borderColor:"rgba("+l.r+","+l.g+","+l.b+", 1)",background:"rgba("+l.r+","+l.g+","+l.b+", 1)"}),this.animation=this.element.animate({boxShadow:["0 0 0 0 rgba("+l.r+","+l.g+","+l.b+",1)","0 0 0 20px rgba("+l.r+","+l.g+","+l.b+", 0)"]},{duration:null!==(s=null==e?void 0:e.duration)&&void 0!==s?s:1500,iterations:null!==(r=null==e?void 0:e.iterations)&&void 0!==r?r:1/0}),this.animation.cancel()}return e.prototype.start=function(){this.element.style.display="block",this.animation.play()},e.prototype.stop=function(){this.animation.cancel(),this.element.style.display="none"},e.prototype.pause=function(){this.animation.pause()},e.prototype.reverse=function(){this.animation.reverse()},e.prototype.getElement=function(){return this.element},e.prototype.startByMouseEvent=function(e){this.element.style.left=e.pageX-this.element.offsetWidth/2+"px",this.element.style.top=e.pageY-this.element.offsetHeight/2+"px",this.start()},e}();var t=document.querySelector(".demo-space"),n=new e({style:{width:"20px",height:"20px"},color:{r:244,g:67,b:54},duration:1200,iterations:10}),i=n.getElement();if(i.style.position="absolute",null===t)throw new Error("Parent node is null");t.appendChild(i),t.addEventListener("click",(function(e){e instanceof MouseEvent&&n.startByMouseEvent(e)})),i.addEventListener("mouseover",(function(){return n.pause()})),i.addEventListener("mouseleave",(function(){return n.start()})),window.addEventListener("keydown",(function(e){switch(e.key){case"Escape":n.stop();break;case"Enter":n.reverse()}}))})();
//# sourceMappingURL=demo.bundle.js.map