Socket
Socket
Sign inDemoInstall

react-confetti

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-confetti - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

9

lib/react-confetti.js

@@ -1,2 +0,2 @@

/*! react-confetti - 1.1.1 | (c) 2015, 2017 Aaron Lampros <alampros@gmail.com> | MIT | https://github.com/alampros/react-confetti#readme */
/*! react-confetti - 1.1.2 | (c) 2015, 2017 Aaron Lampros <alampros@gmail.com> | MIT | https://github.com/alampros/react-confetti#readme */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -448,3 +448,3 @@ if(typeof exports === 'object' && typeof module === 'object')

value: function componentDidMount() {
this.confetti = (0, _confetti2.default)(this.confetti).numberOfPieces(this.props.numberOfPieces).friction(this.props.friction).wind(this.props.wind).gravity(this.props.gravity).colors(this.props.colors).opacity(this.props.opacity)();
this.confetti = (0, _confetti2.default)(this.canvas).numberOfPieces(this.props.numberOfPieces).friction(this.props.friction).wind(this.props.wind).gravity(this.props.gravity).colors(this.props.colors).opacity(this.props.opacity)();
}

@@ -454,5 +454,2 @@ }, {

value: function componentWillReceiveProps(nextProps) {
if (!this.confetti) {
return;
}
this.confetti.numberOfPieces(nextProps.numberOfPieces).friction(nextProps.friction).wind(nextProps.wind).gravity(nextProps.gravity).colors(nextProps.colors).opacity(nextProps.opacity);

@@ -486,3 +483,3 @@ }

ref: function ref(c) {
return _this2.confetti = c;
return _this2.canvas = c;
},

@@ -489,0 +486,0 @@ style: canvasStyles

@@ -1,2 +0,2 @@

/*! react-confetti - 1.1.1 | (c) 2015, 2017 Aaron Lampros <alampros@gmail.com> | MIT | https://github.com/alampros/react-confetti#readme */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactConfetti=e(require("react")):t.ReactConfetti=e(t.React)}(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/lib",e(e.s=3)}([function(t,e,n){"use strict";function i(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function r(t){function e(){function u(t,e){this.radius=s.randomRange(.1,1),this.x=t,this.y=e,this.vx=s.randomRange(-4,4),this.vy=s.randomRange(-10,-0),this.type=s.randomInt(0,1),this.w=s.randomRange(5,20),this.h=s.randomRange(5,20),this.r=s.randomRange(5,10),this.angle=s.degreesToRads(s.randomRange(0,360)),this.anglespin=s.randomRange(-.2,.2),this.color=a[Math.floor(Math.random()*a.length)],this.rotateY=s.randomRange(0,1)}function c(t,e,n,i,r,o){this.x=t,this.y=e,this.w=n,this.h=i,this.number=r,this.particles=[],this.text=o,this.recycle=!0,this.type=1}function l(){0===g.type?(g.type=1,g.x=y/2,g.y=m/2,g.w=0):(g.type=0,g.x=1,g.w=y,g.y=0)}function f(){g.number=n,d.fillStyle="white",d.clearRect(0,0,y,m),g.animate(),requestAnimationFrame(f)}var p=t,d=p.getContext("2d"),y=window.innerWidth||Math.max(document.documentElement.clientWidth,document.body.clientWidth),m=window.innerHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight);p.width=y,p.height=m,u.prototype.update=function(){if(this.x+=this.vx,this.y+=this.vy,this.vy+=o,this.vx+=r,this.vx*=i,this.vy*=i,this.radius-=.02,this.rotateY<1?this.rotateY+=.1:this.rotateY=-1,this.angle+=this.anglespin,d.save(),d.translate(this.x,this.y),d.rotate(this.angle),d.scale(1,this.rotateY),d.rotate(this.angle),d.beginPath(),d.fillStyle=this.color,d.strokeStyle=this.color,d.globalAlpha=h,d.lineCap="round",d.lineWidth=2,0===this.type)d.beginPath(),d.arc(0,0,this.r,0,2*Math.PI),d.fill();else if(2===this.type){d.beginPath();for(var t=0;t<22;t++){var e=.5*t,n=(.2+1.5*e)*Math.cos(e),s=(.2+1.5*e)*Math.sin(e);d.lineTo(n,s)}d.stroke()}else 1===this.type&&d.fillRect(-this.w/2,-this.h/2,this.w,this.h);d.closePath(),d.restore()},c.prototype.animate=function(){if(d.fillStyle="grey",d.beginPath(),d.strokeRect(this.x,this.y,this.w,this.h),d.font="13px arial",d.textAlign="center",d.closePath(),this.particles.length<this.number){var t=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),e=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles.push(new u(t,e,this.text))}this.particles.length>this.number&&(this.particles.length=this.number);for(var n=0;n<this.particles.length;n++){var i=this.particles[n];if(i.update(),(i.y>m||i.y<-100||i.x>y+100||i.x<-100)&&this.recycle){var r=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),o=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles[n]=new u(r,o,this.text)}}};var g=new c(0,0,y,0,n);return l(),f(),e}var n=200,i=.99,r=0,o=.1,a=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],h=1;return e.numberOfPieces=function(){return arguments.length?(n=arguments.length<=0?void 0:arguments[0],e):n},e.friction=function(){return arguments.length?(i=arguments.length<=0?void 0:arguments[0],e):i},e.wind=function(){return arguments.length?(r=arguments.length<=0?void 0:arguments[0],e):r},e.gravity=function(){return arguments.length?(o=arguments.length<=0?void 0:arguments[0],e):o},e.colors=function(){return arguments.length?(a=arguments.length<=0?void 0:arguments[0],e):a},e.opacity=function(){return arguments.length?(h=arguments.length<=0?void 0:arguments[0],e):h},e}Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),s=i(o);e.default=r},function(e,n){e.exports=t},function(t,e,n){"use strict";function i(t,e,n){return(t-e)/(n-e)}function r(t,e,n){return(n-e)*t+e}function o(t,e,n,o,s){return r(i(t,e,n),o,s)}function s(t,e,n){return Math.min(Math.max(t,Math.min(e,n)),Math.max(e,n))}function a(t,e){var n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}function h(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}function u(t,e){return a(t,e)<=t.radius+e.radius}function c(t,e,n){return h(t,e,n.x,n.y)<n.radius}function l(t,e,n){return t>=Math.min(e,n)&&t<=Math.max(e,n)}function f(t,e,n){return l(t,n.x,n.x+n.width)&&l(e,n.y,n.y+n.height)}function p(t,e,n,i){return Math.max(t,e)>=Math.min(n,i)&&Math.min(t,e)<=Math.max(n,i)}function d(t,e){return p(t.x,t.x+t.width,e.x,e.x+e.width)&&p(t.y,t.y+t.height,e.y,e.y+e.height)}function y(t){return t/(180*Math.PI)}function m(t){return 180*t/Math.PI}function g(t,e){return t+Math.random()*(e-t)}function b(t,e){return Math.floor(t+Math.random()*(e-t+1))}Object.defineProperty(e,"__esModule",{value:!0}),e.norm=i,e.lerp=r,e.map=o,e.clamp=s,e.distance=a,e.distanceXY=h,e.circleCollision=u,e.circlePointCollision=c,e.inRange=l,e.pointInRect=f,e.rangeIntersect=p,e.rectIntersect=d,e.degreesToRads=y,e.radsToDegrees=m,e.randomRange=g,e.randomInt=b},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(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)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),h=n(1),u=i(h),c=n(0),l=i(c),f=function(t){function e(){return r(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),a(e,[{key:"componentDidMount",value:function(){this.confetti=(0,l.default)(this.confetti).numberOfPieces(this.props.numberOfPieces).friction(this.props.friction).wind(this.props.wind).gravity(this.props.gravity).colors(this.props.colors).opacity(this.props.opacity)()}},{key:"componentWillReceiveProps",value:function(t){this.confetti&&this.confetti.numberOfPieces(t.numberOfPieces).friction(t.friction).wind(t.wind).gravity(t.gravity).colors(t.colors).opacity(t.opacity)}},{key:"render",value:function(){var t=this,e=this.props,n=e.width,i=e.height,r=e.style,o=Object.assign({},{zIndex:2,position:"absolute",top:0,left:0,width:n,height:i,pointerEvents:"none",WebkitPointerEvents:"none",MozPointerEvents:"none"},r);return u.default.createElement("canvas",{width:n,height:i,ref:function(e){return t.confetti=e},style:o})}}]),e}(u.default.Component);f.propTypes={style:u.default.PropTypes.object,width:u.default.PropTypes.oneOfType([u.default.PropTypes.number,u.default.PropTypes.string]),height:u.default.PropTypes.oneOfType([u.default.PropTypes.number,u.default.PropTypes.string]),numberOfPieces:u.default.PropTypes.number,friction:u.default.PropTypes.number,wind:u.default.PropTypes.number,gravity:u.default.PropTypes.number,colors:u.default.PropTypes.arrayOf(u.default.PropTypes.string),opacity:u.default.PropTypes.number},f.defaultProps={width:"100%",height:"100%",numberOfPieces:200,friction:.99,wind:0,gravity:.1,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1},e.default=f}])});
/*! react-confetti - 1.1.2 | (c) 2015, 2017 Aaron Lampros <alampros@gmail.com> | MIT | https://github.com/alampros/react-confetti#readme */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactConfetti=e(require("react")):t.ReactConfetti=e(t.React)}(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/lib",e(e.s=3)}([function(t,e,n){"use strict";function i(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function r(t){function e(){function u(t,e){this.radius=a.randomRange(.1,1),this.x=t,this.y=e,this.vx=a.randomRange(-4,4),this.vy=a.randomRange(-10,-0),this.type=a.randomInt(0,1),this.w=a.randomRange(5,20),this.h=a.randomRange(5,20),this.r=a.randomRange(5,10),this.angle=a.degreesToRads(a.randomRange(0,360)),this.anglespin=a.randomRange(-.2,.2),this.color=s[Math.floor(Math.random()*s.length)],this.rotateY=a.randomRange(0,1)}function c(t,e,n,i,r,o){this.x=t,this.y=e,this.w=n,this.h=i,this.number=r,this.particles=[],this.text=o,this.recycle=!0,this.type=1}function l(){0===g.type?(g.type=1,g.x=y/2,g.y=m/2,g.w=0):(g.type=0,g.x=1,g.w=y,g.y=0)}function f(){g.number=n,d.fillStyle="white",d.clearRect(0,0,y,m),g.animate(),requestAnimationFrame(f)}var p=t,d=p.getContext("2d"),y=window.innerWidth||Math.max(document.documentElement.clientWidth,document.body.clientWidth),m=window.innerHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight);p.width=y,p.height=m,u.prototype.update=function(){if(this.x+=this.vx,this.y+=this.vy,this.vy+=o,this.vx+=r,this.vx*=i,this.vy*=i,this.radius-=.02,this.rotateY<1?this.rotateY+=.1:this.rotateY=-1,this.angle+=this.anglespin,d.save(),d.translate(this.x,this.y),d.rotate(this.angle),d.scale(1,this.rotateY),d.rotate(this.angle),d.beginPath(),d.fillStyle=this.color,d.strokeStyle=this.color,d.globalAlpha=h,d.lineCap="round",d.lineWidth=2,0===this.type)d.beginPath(),d.arc(0,0,this.r,0,2*Math.PI),d.fill();else if(2===this.type){d.beginPath();for(var t=0;t<22;t++){var e=.5*t,n=(.2+1.5*e)*Math.cos(e),a=(.2+1.5*e)*Math.sin(e);d.lineTo(n,a)}d.stroke()}else 1===this.type&&d.fillRect(-this.w/2,-this.h/2,this.w,this.h);d.closePath(),d.restore()},c.prototype.animate=function(){if(d.fillStyle="grey",d.beginPath(),d.strokeRect(this.x,this.y,this.w,this.h),d.font="13px arial",d.textAlign="center",d.closePath(),this.particles.length<this.number){var t=a.clamp(a.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),e=a.clamp(a.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles.push(new u(t,e,this.text))}this.particles.length>this.number&&(this.particles.length=this.number);for(var n=0;n<this.particles.length;n++){var i=this.particles[n];if(i.update(),(i.y>m||i.y<-100||i.x>y+100||i.x<-100)&&this.recycle){var r=a.clamp(a.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),o=a.clamp(a.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles[n]=new u(r,o,this.text)}}};var g=new c(0,0,y,0,n);return l(),f(),e}var n=200,i=.99,r=0,o=.1,s=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],h=1;return e.numberOfPieces=function(){return arguments.length?(n=arguments.length<=0?void 0:arguments[0],e):n},e.friction=function(){return arguments.length?(i=arguments.length<=0?void 0:arguments[0],e):i},e.wind=function(){return arguments.length?(r=arguments.length<=0?void 0:arguments[0],e):r},e.gravity=function(){return arguments.length?(o=arguments.length<=0?void 0:arguments[0],e):o},e.colors=function(){return arguments.length?(s=arguments.length<=0?void 0:arguments[0],e):s},e.opacity=function(){return arguments.length?(h=arguments.length<=0?void 0:arguments[0],e):h},e}Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),a=i(o);e.default=r},function(e,n){e.exports=t},function(t,e,n){"use strict";function i(t,e,n){return(t-e)/(n-e)}function r(t,e,n){return(n-e)*t+e}function o(t,e,n,o,a){return r(i(t,e,n),o,a)}function a(t,e,n){return Math.min(Math.max(t,Math.min(e,n)),Math.max(e,n))}function s(t,e){var n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}function h(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}function u(t,e){return s(t,e)<=t.radius+e.radius}function c(t,e,n){return h(t,e,n.x,n.y)<n.radius}function l(t,e,n){return t>=Math.min(e,n)&&t<=Math.max(e,n)}function f(t,e,n){return l(t,n.x,n.x+n.width)&&l(e,n.y,n.y+n.height)}function p(t,e,n,i){return Math.max(t,e)>=Math.min(n,i)&&Math.min(t,e)<=Math.max(n,i)}function d(t,e){return p(t.x,t.x+t.width,e.x,e.x+e.width)&&p(t.y,t.y+t.height,e.y,e.y+e.height)}function y(t){return t/(180*Math.PI)}function m(t){return 180*t/Math.PI}function g(t,e){return t+Math.random()*(e-t)}function b(t,e){return Math.floor(t+Math.random()*(e-t+1))}Object.defineProperty(e,"__esModule",{value:!0}),e.norm=i,e.lerp=r,e.map=o,e.clamp=a,e.distance=s,e.distanceXY=h,e.circleCollision=u,e.circlePointCollision=c,e.inRange=l,e.pointInRect=f,e.rangeIntersect=p,e.rectIntersect=d,e.degreesToRads=y,e.radsToDegrees=m,e.randomRange=g,e.randomInt=b},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(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)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),h=n(1),u=i(h),c=n(0),l=i(c),f=function(t){function e(){return r(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),s(e,[{key:"componentDidMount",value:function(){this.confetti=(0,l.default)(this.canvas).numberOfPieces(this.props.numberOfPieces).friction(this.props.friction).wind(this.props.wind).gravity(this.props.gravity).colors(this.props.colors).opacity(this.props.opacity)()}},{key:"componentWillReceiveProps",value:function(t){this.confetti.numberOfPieces(t.numberOfPieces).friction(t.friction).wind(t.wind).gravity(t.gravity).colors(t.colors).opacity(t.opacity)}},{key:"render",value:function(){var t=this,e=this.props,n=e.width,i=e.height,r=e.style,o=Object.assign({},{zIndex:2,position:"absolute",top:0,left:0,width:n,height:i,pointerEvents:"none",WebkitPointerEvents:"none",MozPointerEvents:"none"},r);return u.default.createElement("canvas",{width:n,height:i,ref:function(e){return t.canvas=e},style:o})}}]),e}(u.default.Component);f.propTypes={style:u.default.PropTypes.object,width:u.default.PropTypes.oneOfType([u.default.PropTypes.number,u.default.PropTypes.string]),height:u.default.PropTypes.oneOfType([u.default.PropTypes.number,u.default.PropTypes.string]),numberOfPieces:u.default.PropTypes.number,friction:u.default.PropTypes.number,wind:u.default.PropTypes.number,gravity:u.default.PropTypes.number,colors:u.default.PropTypes.arrayOf(u.default.PropTypes.string),opacity:u.default.PropTypes.number},f.defaultProps={width:"100%",height:"100%",numberOfPieces:200,friction:.99,wind:0,gravity:.1,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1},e.default=f}])});
{
"name": "react-confetti",
"version": "1.1.1",
"version": "1.1.2",
"description": "React component to draw confetti for your party.",

@@ -5,0 +5,0 @@ "main": "lib/react-confetti.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc