vue-confetti
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,485 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["vue-confetti"] = factory(); | ||
else | ||
root["vue-confetti"] = factory(); | ||
})(this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__confetti__ = __webpack_require__(1); | ||
/* harmony default export */ __webpack_exports__["default"] = ({ | ||
install: function install(Vue, options) { | ||
if (this.installed) { | ||
return; | ||
} | ||
this.installed = true; | ||
Vue.prototype.$confetti = new __WEBPACK_IMPORTED_MODULE_0__confetti__["a" /* default */](options); | ||
} | ||
}); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__particles__ = __webpack_require__(2); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Confetti = function () { | ||
function Confetti() { | ||
_classCallCheck(this, Confetti); | ||
this.ctx = null; | ||
this.W = 0; | ||
this.H = 0; | ||
this.particles = {}; | ||
this.droppedCount = 0; | ||
this.particlesPerFrame = 1.5; | ||
this.wind = 0; | ||
this.windSpeed = 1; | ||
this.windSpeedMax = 1; | ||
this.windChange = 0.01; | ||
this.windPosCoef = 0.002; | ||
this.maxParticlesPerFrame = 2; // max particles dropped per frame | ||
} | ||
/** | ||
* Create the confetti particles. | ||
*/ | ||
_createClass(Confetti, [{ | ||
key: 'createParticles', | ||
value: function createParticles(opts) { | ||
this.particles = new __WEBPACK_IMPORTED_MODULE_0__particles__["a" /* default */]({ | ||
ctx: this.ctx, | ||
W: this.W, | ||
H: this.H, | ||
wind: this.wind, | ||
windPosCoef: this.windPosCoef, | ||
windSpeedMax: this.windSpeedMax, | ||
count: 0, | ||
shape: opts.shape || 'circle', | ||
colors: { | ||
opts: opts.colors || ['DodgerBlue', 'OliveDrab', 'Gold', 'pink', 'SlateBlue', 'lightblue', 'Violet', 'PaleGreen', 'SteelBlue', 'SandyBrown', 'Chocolate', 'Crimson'], | ||
idx: 0, | ||
step: 10, | ||
get color() { | ||
return this.opts[(this.idx++ / this.step | 0) % this.opts.length]; | ||
} | ||
} | ||
}); | ||
} | ||
/** | ||
* Add a fixed, full-screen canvas to the page. | ||
*/ | ||
}, { | ||
key: 'createContext', | ||
value: function createContext() { | ||
this.canvas = document.createElement('canvas'); | ||
this.ctx = this.canvas.getContext('2d'); | ||
this.canvas.style.display = 'block'; | ||
this.canvas.style.position = 'fixed'; | ||
this.canvas.style.pointerEvents = 'none'; | ||
this.canvas.style.top = 0; | ||
this.canvas.style.width = '100vw'; | ||
this.canvas.style.height = '100vh'; | ||
this.canvas.id = 'confetti-canvas'; | ||
document.querySelector('body').appendChild(this.canvas); | ||
} | ||
/** | ||
* Start dropping confetti. | ||
* @param {Object} opts | ||
* The particle options. | ||
*/ | ||
}, { | ||
key: 'start', | ||
value: function start(opts) { | ||
if (!this.ctx) { | ||
this.createContext(); | ||
} | ||
this.createParticles(opts); | ||
this.updateDimensions(); | ||
this.particlesPerFrame = this.maxParticlesPerFrame; | ||
requestAnimationFrame(this.mainLoop.bind(this)); | ||
window.addEventListener('resize', this.updateDimensions.bind(this)); | ||
} | ||
/** | ||
* Stop dropping confetti. | ||
*/ | ||
}, { | ||
key: 'stop', | ||
value: function stop() { | ||
this.particlesPerFrame = 0; | ||
window.removeEventListener('resize', this.updateDimensions); | ||
} | ||
/** | ||
* Update the dimensions, if necessary. | ||
*/ | ||
}, { | ||
key: 'updateDimensions', | ||
value: function updateDimensions() { | ||
if (this.W !== window.innerWidth || this.H !== window.innerHeight) { | ||
this.W = this.particles.opts.W = this.canvas.width = window.innerWidth; | ||
this.H = this.particles.opts.H = this.canvas.height = window.innerHeight; | ||
} | ||
} | ||
/** | ||
* Run the main animation loop. | ||
*/ | ||
}, { | ||
key: 'mainLoop', | ||
value: function mainLoop(time) { | ||
this.updateDimensions(); | ||
this.ctx.setTransform(1, 0, 0, 1, 0, 0); | ||
this.ctx.clearRect(0, 0, this.W, this.H); | ||
this.windSpeed = Math.sin(time / 8000) * this.windSpeedMax; | ||
this.wind = this.particles.opts.wind += this.windChange; | ||
while (this.droppedCount < this.particlesPerFrame) { | ||
this.droppedCount += 1; | ||
this.particles.add(); | ||
} | ||
this.droppedCount -= this.particlesPerFrame; | ||
this.particles.update(); | ||
this.particles.draw(); | ||
requestAnimationFrame(this.mainLoop.bind(this)); | ||
} | ||
}]); | ||
return Confetti; | ||
}(); | ||
/* harmony default export */ __webpack_exports__["a"] = (Confetti); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__particle__ = __webpack_require__(3); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Particles = function () { | ||
function Particles(opts) { | ||
_classCallCheck(this, Particles); | ||
this.items = []; | ||
this.pool = []; | ||
this.opts = opts; | ||
} | ||
/** | ||
* Move the particle back to the pool if it is past the bottom. | ||
*/ | ||
_createClass(Particles, [{ | ||
key: 'update', | ||
value: function update() { | ||
for (var i = 0; i < this.items.length; i++) { | ||
if (this.items[i].update() === true) { | ||
this.pool.push(this.items.splice(i--, 1)[0]); | ||
} | ||
} | ||
} | ||
/** | ||
* Draw the particles currently in view. | ||
*/ | ||
}, { | ||
key: 'draw', | ||
value: function draw() { | ||
for (var i = 0; i < this.items.length; i++) { | ||
this.items[i].draw(); | ||
} | ||
} | ||
/** | ||
* Add an item to the view. | ||
*/ | ||
}, { | ||
key: 'add', | ||
value: function add() { | ||
if (this.pool.length > 0) { | ||
this.items.push(this.pool.pop().setup(this.opts)); | ||
} else { | ||
this.items.push(new __WEBPACK_IMPORTED_MODULE_0__particle__["a" /* default */]().setup(this.opts)); | ||
} | ||
} | ||
}]); | ||
return Particles; | ||
}(); | ||
/* harmony default export */ __webpack_exports__["a"] = (Particles); | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Particle = function () { | ||
function Particle() { | ||
_classCallCheck(this, Particle); | ||
} | ||
_createClass(Particle, [{ | ||
key: 'setup', | ||
/** | ||
* Setup the particle. | ||
* @param {options} opts | ||
* The particle options | ||
*/ | ||
value: function setup(_ref) { | ||
var ctx = _ref.ctx, | ||
W = _ref.W, | ||
H = _ref.H, | ||
colors = _ref.colors, | ||
wind = _ref.wind, | ||
windPosCoef = _ref.windPosCoef, | ||
windSpeedMax = _ref.windSpeedMax, | ||
count = _ref.count, | ||
shape = _ref.shape; | ||
this.ctx = ctx; | ||
this.W = W; | ||
this.H = H; | ||
this.wind = wind; | ||
this.shape = shape; | ||
this.windPosCoef = windPosCoef; | ||
this.windSpeedMax = windSpeedMax; | ||
this.x = this.rand(-35, W + 35); | ||
this.y = this.rand(-30, -35); | ||
this.d = this.rand(150) + 10; // density | ||
this.r = this.rand(10, 30); | ||
this.color = colors.color; // get the next color | ||
this.tilt = this.randI(10); | ||
this.tiltAngleIncremental = (this.rand(0.08) + 0.04) * (this.rand() < 0.5 ? -1 : 1); | ||
this.tiltAngle = 0; | ||
this.angle = this.rand(Math.PI * 2); | ||
this.count = count++; | ||
return this; | ||
} | ||
/** | ||
* Return a random number. | ||
* @param {Number} min | ||
* The minimum number. | ||
* @param {Number} max | ||
* The maximum number. | ||
*/ | ||
}, { | ||
key: 'randI', | ||
value: function randI(min) { | ||
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : min + (min = 0); | ||
return Math.random() * (max - min) + min | 0; | ||
} | ||
/** | ||
* Return a random number with a minimum of one. | ||
* @param {Number} min | ||
* The minimum number. | ||
* @param {Number} max | ||
* The maximum number. | ||
*/ | ||
}, { | ||
key: 'rand', | ||
value: function rand() { | ||
var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : min + (min = 0); | ||
return Math.random() * (max - min) + min; | ||
} | ||
/** | ||
* Update the particle. | ||
*/ | ||
}, { | ||
key: 'update', | ||
value: function update() { | ||
this.tiltAngle += this.tiltAngleIncremental * (Math.cos(this.wind + (this.d + this.x + this.y) * this.windPosCoef) * 0.2 + 1); | ||
this.y += (Math.cos(this.angle + this.d) + 3 + this.r / 2) / 2; | ||
this.x += Math.sin(this.angle); | ||
this.x += Math.cos(this.wind + (this.d + this.x + this.y) * this.windPosCoef) * this.windSpeedMax; | ||
this.y += Math.sin(this.wind + (this.d + this.x + this.y) * this.windPosCoef) * this.windSpeedMax; | ||
this.tilt = Math.sin(this.tiltAngle - this.count / 3) * 15; | ||
return this.y > this.H; // returns true if particle is past bottom | ||
} | ||
/** | ||
* Draw a round particle. | ||
*/ | ||
}, { | ||
key: 'drawCircle', | ||
value: function drawCircle() { | ||
this.ctx.arc(0, 0, this.r / 2, 0, Math.PI * 2, false); | ||
this.ctx.fill(); | ||
} | ||
/** | ||
* Draw a rectangular particle. | ||
*/ | ||
}, { | ||
key: 'drawRect', | ||
value: function drawRect() { | ||
this.ctx.fillRect(0, 0, this.r, this.r / 2); | ||
} | ||
/** | ||
* Draw a heart-shaped particle. | ||
*/ | ||
}, { | ||
key: 'drawHeart', | ||
value: function drawHeart() { | ||
var _this = this; | ||
var curveTo = function curveTo(cp1x, cp1y, cp2x, cp2y, x, y) { | ||
_this.ctx.bezierCurveTo(cp1x / _this.r * 2, cp1y / _this.r * 2, cp2x / _this.r * 2, cp2y / _this.r * 2, x / _this.r * 2, y / _this.r * 2); | ||
}; | ||
this.ctx.moveTo(37.5 / this.r, 20 / this.r); | ||
curveTo(75, 37, 70, 25, 50, 25); | ||
curveTo(20, 25, 20, 62.5, 20, 62.5); | ||
curveTo(20, 80, 40, 102, 75, 120); | ||
curveTo(110, 102, 130, 80, 130, 62.5); | ||
curveTo(130, 62.5, 130, 25, 100, 25); | ||
curveTo(85, 25, 75, 37, 75, 40); | ||
this.ctx.fill(); | ||
} | ||
/** | ||
* Draw a particle. | ||
*/ | ||
}, { | ||
key: 'draw', | ||
value: function draw() { | ||
this.ctx.fillStyle = this.color; | ||
this.ctx.beginPath(); | ||
this.ctx.setTransform(Math.cos(this.tiltAngle), // set the x axis to the tilt angle | ||
Math.sin(this.tiltAngle), 0, 1, this.x, this.y // set the origin | ||
); | ||
if (this.shape === 'circle') { | ||
this.drawCircle(); | ||
} else if (this.shape === 'rect') { | ||
this.drawRect(); | ||
} else if (this.shape === 'heart') { | ||
this.drawHeart(); | ||
} | ||
} | ||
}]); | ||
return Particle; | ||
}(); | ||
/* harmony default export */ __webpack_exports__["a"] = (Particle); | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports["vue-confetti"]=i():t["vue-confetti"]=i()}(this,function(){return function(t){function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}var e={};return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},i.p="",i(i.s=0)}([function(t,i,e){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=e(1);i.default={install:function(t,i){this.installed||(this.installed=!0,t.prototype.$confetti=new n.a(i))}}},function(t,i,e){"use strict";function n(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var s=e(2),r=function(){function t(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(i,e,n){return e&&t(i.prototype,e),n&&t(i,n),i}}(),a=function(){function t(){n(this,t),this.ctx=null,this.W=0,this.H=0,this.particles={},this.droppedCount=0,this.particlesPerFrame=1.5,this.wind=0,this.windSpeed=1,this.windSpeedMax=1,this.windChange=.01,this.windPosCoef=.002,this.maxParticlesPerFrame=2}return r(t,[{key:"createParticles",value:function(t){this.particles=new s.a({ctx:this.ctx,W:this.W,H:this.H,wind:this.wind,windPosCoef:this.windPosCoef,windSpeedMax:this.windSpeedMax,count:0,shape:t.shape||"circle",colors:{opts:t.colors||["DodgerBlue","OliveDrab","Gold","pink","SlateBlue","lightblue","Violet","PaleGreen","SteelBlue","SandyBrown","Chocolate","Crimson"],idx:0,step:10,get color(){return this.opts[(this.idx++/this.step|0)%this.opts.length]}}})}},{key:"createContext",value:function(){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.canvas.style.display="block",this.canvas.style.position="fixed",this.canvas.style.pointerEvents="none",this.canvas.style.top=0,this.canvas.style.width="100vw",this.canvas.style.height="100vh",this.canvas.id="confetti-canvas",document.querySelector("body").appendChild(this.canvas)}},{key:"start",value:function(t){this.ctx||this.createContext(),this.createParticles(t),this.updateDimensions(),this.particlesPerFrame=this.maxParticlesPerFrame,requestAnimationFrame(this.mainLoop.bind(this)),window.addEventListener("resize",this.updateDimensions.bind(this))}},{key:"stop",value:function(){this.particlesPerFrame=0,window.removeEventListener("resize",this.updateDimensions)}},{key:"updateDimensions",value:function(){this.W===window.innerWidth&&this.H===window.innerHeight||(this.W=this.particles.opts.W=this.canvas.width=window.innerWidth,this.H=this.particles.opts.H=this.canvas.height=window.innerHeight)}},{key:"mainLoop",value:function(t){for(this.updateDimensions(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.W,this.H),this.windSpeed=Math.sin(t/8e3)*this.windSpeedMax,this.wind=this.particles.opts.wind+=this.windChange;this.droppedCount<this.particlesPerFrame;)this.droppedCount+=1,this.particles.add();this.droppedCount-=this.particlesPerFrame,this.particles.update(),this.particles.draw(),requestAnimationFrame(this.mainLoop.bind(this))}}]),t}();i.a=a},function(t,i,e){"use strict";function n(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var s=e(3),r=function(){function t(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(i,e,n){return e&&t(i.prototype,e),n&&t(i,n),i}}(),a=function(){function t(i){n(this,t),this.items=[],this.pool=[],this.opts=i}return r(t,[{key:"update",value:function(){for(var t=0;t<this.items.length;t++)!0===this.items[t].update()&&this.pool.push(this.items.splice(t--,1)[0])}},{key:"draw",value:function(){for(var t=0;t<this.items.length;t++)this.items[t].draw()}},{key:"add",value:function(){this.pool.length>0?this.items.push(this.pool.pop().setup(this.opts)):this.items.push((new s.a).setup(this.opts))}}]),t}();i.a=a},function(t,i,e){"use strict";function n(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var s=function(){function t(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(i,e,n){return e&&t(i.prototype,e),n&&t(i,n),i}}(),r=function(){function t(){n(this,t)}return s(t,[{key:"setup",value:function(t){var i=t.ctx,e=t.W,n=t.H,s=t.colors,r=t.wind,a=t.windPosCoef,h=t.windSpeedMax,o=t.count,c=t.shape;return this.ctx=i,this.W=e,this.H=n,this.wind=r,this.shape=c,this.windPosCoef=a,this.windSpeedMax=h,this.x=this.rand(-35,e+35),this.y=this.rand(-30,-35),this.d=this.rand(150)+10,this.r=this.rand(10,30),this.color=s.color,this.tilt=this.randI(10),this.tiltAngleIncremental=(this.rand(.08)+.04)*(this.rand()<.5?-1:1),this.tiltAngle=0,this.angle=this.rand(2*Math.PI),this.count=o++,this}},{key:"randI",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+(t=0);return Math.random()*(i-t)+t|0}},{key:"rand",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+(t=0);return Math.random()*(i-t)+t}},{key:"update",value:function(){return this.tiltAngle+=this.tiltAngleIncremental*(.2*Math.cos(this.wind+(this.d+this.x+this.y)*this.windPosCoef)+1),this.y+=(Math.cos(this.angle+this.d)+3+this.r/2)/2,this.x+=Math.sin(this.angle),this.x+=Math.cos(this.wind+(this.d+this.x+this.y)*this.windPosCoef)*this.windSpeedMax,this.y+=Math.sin(this.wind+(this.d+this.x+this.y)*this.windPosCoef)*this.windSpeedMax,this.tilt=15*Math.sin(this.tiltAngle-this.count/3),this.y>this.H}},{key:"drawCircle",value:function(){this.ctx.arc(0,0,this.r/2,0,2*Math.PI,!1),this.ctx.fill()}},{key:"drawRect",value:function(){this.ctx.fillRect(0,0,this.r,this.r/2)}},{key:"drawHeart",value:function(){var t=this,i=function(i,e,n,s,r,a){t.ctx.bezierCurveTo(i/t.r*2,e/t.r*2,n/t.r*2,s/t.r*2,r/t.r*2,a/t.r*2)};this.ctx.moveTo(37.5/this.r,20/this.r),i(75,37,70,25,50,25),i(20,25,20,62.5,20,62.5),i(20,80,40,102,75,120),i(110,102,130,80,130,62.5),i(130,62.5,130,25,100,25),i(85,25,75,37,75,40),this.ctx.fill()}},{key:"draw",value:function(){this.ctx.fillStyle=this.color,this.ctx.beginPath(),this.ctx.setTransform(Math.cos(this.tiltAngle),Math.sin(this.tiltAngle),0,1,this.x,this.y),"circle"===this.shape?this.drawCircle():"rect"===this.shape?this.drawRect():"heart"===this.shape&&this.drawHeart()}}]),t}();i.a=r}])}); |
{ | ||
"name": "vue-confetti", | ||
"description": "A Vue component for dropping confetti.", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "dist/vue-confetti.js", | ||
@@ -6,0 +6,0 @@ "author": "Alex Mendes <alexanderhmendes@gmail.com>", |
@@ -1,7 +0,8 @@ | ||
const resolve = require('path').resolve | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
module.exports = { | ||
entry: resolve(__dirname, 'src', 'index.js'), | ||
entry: path.resolve(__dirname, 'src', 'index.js'), | ||
output: { | ||
path: resolve(__dirname, 'dist'), | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'vue-confetti.js', | ||
@@ -19,3 +20,6 @@ library: 'vue-confetti', | ||
] | ||
} | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin() | ||
] | ||
} |
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
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
18689
328