js-confetti
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.jsConfetti=t():e.jsConfetti=t()}(self,(function(){return(()=>{"use strict";var e={374:(e,t,n)=>{function o(e){return+e.replace(/px/,"")}function i(e,t){return Math.floor(Math.random()*(t-e+1))+e}n.r(t),n.d(t,{default:()=>f});var r=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc9003"];function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var u=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.speedX=.1*i(500,900)/100,this.speedY=.1*i(500,900)/100,this.radius=10,this.angle="left"===n?i(-140,0)*Math.PI/180:i(0,-140)*Math.PI/180,this.position=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t),this.color=r[i(0,r.length-1)]}var t,n;return t=e,(n=[{key:"draw",value:function(e){var t=this.position,n=this.radius,o=this.color,i=window.devicePixelRatio;e.fillStyle=o,e.beginPath(),e.arc(t.x*i,t.y*i,n*i,0,2*Math.PI,!0),e.fill()}},{key:"updatePosition",value:function(e){var t=this.speedX,n=this.speedY,o=this.angle;this.position.x+=Math.cos(o)*e*t,this.position.y+=Math.sin(o)*e*n,this.speedY-=5e-4*e}}])&&c(t.prototype,n),e}();function l(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}const f=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.zIndex="1000",this.canvas.style.pointerEvents="none",document.body.appendChild(this.canvas),this.canvasContext=this.canvas.getContext("2d"),this.shapes=[],this.lastUpdated=(new Date).getTime(),setTimeout((function(){return t.loop.call(t)}),0)}var t,n;return t=e,(n=[{key:"loop",value:function(){var e,t,n,i,r,a=this;e=this.canvas,t=window.devicePixelRatio,i=o((n=getComputedStyle(e)).getPropertyValue("width")),r=o(n.getPropertyValue("height")),e.setAttribute("width",(i*t).toString()),e.setAttribute("height",(r*t).toString());var s=(new Date).getTime(),c=s-this.lastUpdated;this.shapes.forEach((function(e){e.updatePosition(c),e.draw(a.canvasContext)})),this.lastUpdated=s,setTimeout((function(){return a.loop.call(a)}),0)}},{key:"addConfetti",value:function(){for(var e=5*window.innerHeight/7,t={x:0,y:e},n={x:window.innerWidth,y:e},o=0;o<50;o++)this.shapes.push(new u(t,"right")),this.shapes.push(new u(n,"left"))}}])&&l(t.prototype,n),e}()}},t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}return n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(374)})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.jsConfetti=e():t.jsConfetti=e()}(self,(function(){return(()=>{"use strict";var t={374:(t,e,n)=>{function i(t){return+t.replace(/px/,"")}function o(t,e){return Math.floor(Math.random()*(e-t+1))+t}n.r(e),n.d(e,{default:()=>f});var r=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc9003"];function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var l=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.speedX=.1*o(500,900)/100,this.speedY=.1*o(500,900)/100,this.radius=10,this.angle="left"===n?o(-140,0)*Math.PI/180:o(0,-140)*Math.PI/180,this.position=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},e),this.color=r[o(0,r.length-1)]}var e,n;return e=t,(n=[{key:"draw",value:function(t){var e=this.position,n=this.radius,i=this.color,o=window.devicePixelRatio;t.fillStyle=i,t.beginPath(),t.arc(e.x*o,e.y*o,n*o,0,2*Math.PI,!0),t.fill()}},{key:"updatePosition",value:function(t){var e=this.speedX,n=this.speedY,i=this.angle;this.position.x+=Math.cos(i)*t*e,this.position.y+=Math.sin(i)*t*n,this.speedY-=5e-4*t}}])&&c(e.prototype,n),t}();function u(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}const f=function(){function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.top="0",this.canvas.style.left="0",this.canvas.style.zIndex="1000",this.canvas.style.pointerEvents="none",document.body.appendChild(this.canvas),this.canvasContext=this.canvas.getContext("2d"),this.shapes=[],this.lastUpdated=(new Date).getTime(),setTimeout((function(){return e.loop.call(e)}),0)}var e,n;return e=t,(n=[{key:"loop",value:function(){var t,e,n,o,r,a=this;t=this.canvas,e=window.devicePixelRatio,o=i((n=getComputedStyle(t)).getPropertyValue("width")),r=i(n.getPropertyValue("height")),t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(r*e).toString());var s=(new Date).getTime(),c=s-this.lastUpdated;this.shapes.forEach((function(t){t.updatePosition(c),t.draw(a.canvasContext)})),this.lastUpdated=s,setTimeout((function(){return a.loop.call(a)}),0)}},{key:"addConfetti",value:function(){for(var t=5*window.innerHeight/7,e={x:0,y:t},n={x:window.innerWidth,y:t},i=0;i<50;i++)this.shapes.push(new l(e,"right")),this.shapes.push(new l(n,"left"))}}])&&u(e.prototype,n),t}()}},e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}return n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(374)})()})); |
{ | ||
"name": "js-confetti", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "js-confetti", |
5611