@wellwind/thanos-snap
Version:
Use [Thanos](https://www.google.com/search?q=Thanos) snap to destory your DOM elements.
2 lines • 2.29 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("html2canvas"),require("ramda")):"function"==typeof define&&define.amd?define("@wellwind/thanos-snap",["exports","html2canvas","ramda"],e):e((t.wellwind=t.wellwind||{},t.wellwind["thanos-snap"]={}),t.html2canvas_,t.ramda)}(this,function(t,e,c){"use strict";function h(s,d,l,t){var h=s.length;c.range(0,l).forEach(function(r){c.range(0,t).forEach(function(o){c.range(0,2).forEach(function(t){for(var e=Math.floor(h*(Math.random()+2*r/l)/3),n=4*(o*l+r),a=0;a<4;a++){var i=n+a;s[e].data[i]=d.data[i]}})})})}function u(t){var e=15*(Math.random()-.5),n=15*(Math.random()-.5),a=2*Math.PI*(Math.random()-.5),i=60*Math.cos(a),o=30*Math.sin(a);t.style.transform="rotate("+e+"deg) translate("+i+"px, "+o+"px) rotate("+n+"deg)",t.style.opacity="0";var r=1e3*(2.5+Math.random());setTimeout(function(){return t.remove()},r)}function f(){return window.devicePixelRatio&&1<window.devicePixelRatio?window.devicePixelRatio:1}function p(e){return new Promise(function(t){e.style.opacity="1",e.style.visibility="visible",t()})}var n=e,a=h,i=u,o=f;t.thanosRewind=p,t.thanosSnap=function(l){return new Promise(function(r){var s=document.createElement("div");s.classList.add("thanos"),l.parentNode.insertBefore(s,l);var d=l.getBoundingClientRect();n(l).then(function(t){var e=t.getContext("2d");s.style.position="absolute",s.style.left=d.left+"px",s.style.top=d.top+"px",s.style.width=d.width+"px",s.style.height=d.height+"px";var n=t.width,a=t.height,i=e.getImageData(0,0,n,a),o=c.range(0,32).map(function(t){return e.createImageData(n,a)});h(o,i,n,a),o.forEach(function(t,e){var n=document.createElement("canvas");n.style.position="absolute",n.style.transition="all 1.5s",n.width=d.width*f(),n.height=d.height*f(),n.style.width=n.width/f()+"px",n.style.height=n.height/f()+"px",n.getContext("2d").putImageData(t,0,0),s.appendChild(n);var a=e/o.length*1.35;n.style.transitionDelay=a+"s",setTimeout(function(){return u(n)},0)}),l.style.transition="opacity 1.5 ease",l.style.opacity="0",setTimeout(function(){l.style.visibility="hidden",s.remove(),r({rewind:function(){return p(l)}})},1500)})})},t.ɵ0=a,t.ɵ1=i,t.ɵ2=o,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=wellwind-thanos-snap.umd.min.js.map