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.0.2 to 1.0.3

25

lib/react-confetti.js

@@ -88,3 +88,3 @@ /*! react-confetti - 1.0.2 | (c) 2015, 2016 Aaron Lampros <alampros@gmail.com> | MIT | https://github.com/alampros/react-confetti#readme */

return _possibleConstructorReturn(this, Object.getPrototypeOf(Confetti).apply(this, arguments));
return _possibleConstructorReturn(this, (Confetti.__proto__ || Object.getPrototypeOf(Confetti)).apply(this, arguments));
}

@@ -95,3 +95,3 @@

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

@@ -131,3 +131,4 @@ }, {

wind: _react2.default.PropTypes.number,
gravity: _react2.default.PropTypes.number
gravity: _react2.default.PropTypes.number,
colors: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string)
};

@@ -140,3 +141,4 @@ Confetti.defaultProps = {

wind: 0,
gravity: 0.1
gravity: 0.1,
colors: ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548']
};

@@ -167,16 +169,15 @@ exports.default = Confetti;

function confetti(canvasObj) {
var numberOfPieces = arguments.length <= 1 || arguments[1] === undefined ? 20 : arguments[1];
var friction = arguments.length <= 2 || arguments[2] === undefined ? 0.99 : arguments[2];
var wind = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
var gravity = arguments.length <= 4 || arguments[4] === undefined ? 0.1 : arguments[4];
var numberOfPieces = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
var friction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.99;
var wind = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
var gravity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0.1;
var colors = arguments[5];
var canvas = canvasObj;
var context = canvas.getContext('2d');
var W = window.innerWidth;
var H = window.innerHeight;
var W = window.innerWidth || Math.max(document.documentElement.clientWidth, document.body.clientWidth);
var H = window.innerHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight);
canvas.width = W;
canvas.height = H;
var colors = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548'];
function Particle(x, y) {

@@ -183,0 +184,0 @@ this.radius = utils.randomRange(0.1, 1);

/*! react-confetti - 1.0.2 | (c) 2015, 2016 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]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="/lib",e(0)}([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(3),u=i(h),c=n(1),l=i(c),f=function(t){function e(){return r(this,e),o(this,Object.getPrototypeOf(e).apply(this,arguments))}return s(e,t),a(e,[{key:"componentDidMount",value:function(){(0,l["default"])(this.refs.confetti,this.props.numberOfPieces,this.props.friction,this.props.wind,this.props.gravity)}},{key:"render",value:function(){var t=Object.assign({},{zIndex:2,position:"absolute",top:0,left:0,width:this.props.width,height:this.props.height,pointerEvents:"none",WebkitPointerEvents:"none",MozPointerEvents:"none"},this.props.style);return u["default"].createElement("canvas",{width:this.props.width,height:this.props.height,ref:"confetti",style:t})}}]),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},f.defaultProps={width:"100%",height:"100%",numberOfPieces:200,friction:.99,wind:0,gravity:.1},e["default"]=f},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(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=d[Math.floor(Math.random()*d.length)],this.rotateY=s.randomRange(0,1)}function n(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 i(){0===y.type?(y.type=1,y.x=f/2,y.y=p/2,y.w=0):(y.type=0,y.x=1,y.w=f,y.y=0)}function r(){y.number=o,l.fillStyle="white",l.clearRect(0,0,f,p),y.animate(),requestAnimationFrame(r)}var o=arguments.length<=1||void 0===arguments[1]?20:arguments[1],a=arguments.length<=2||void 0===arguments[2]?.99:arguments[2],h=arguments.length<=3||void 0===arguments[3]?0:arguments[3],u=arguments.length<=4||void 0===arguments[4]?.1:arguments[4],c=t,l=c.getContext("2d"),f=window.innerWidth,p=window.innerHeight;c.width=f,c.height=p;var d=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"];e.prototype.update=function(){if(this.x+=this.vx,this.y+=this.vy,this.vy+=u,this.vx+=h,this.vx*=a,this.vy*=a,this.radius-=.02,this.rotateY<1?this.rotateY+=.1:this.rotateY=-1,this.angle+=this.anglespin,l.save(),l.translate(this.x,this.y),l.rotate(this.angle),l.scale(1,this.rotateY),l.rotate(this.angle),l.beginPath(),l.fillStyle=this.color,l.strokeStyle=this.color,l.lineCap="round",l.lineWidth=2,0===this.type)l.beginPath(),l.arc(0,0,this.r,0,2*Math.PI),l.fill();else if(2===this.type){l.beginPath();for(var t=0;22>t;t++){var e=.5*t,n=(.2+1.5*e)*Math.cos(e),i=(.2+1.5*e)*Math.sin(e);l.lineTo(n,i)}l.stroke()}else 1===this.type&&l.fillRect(-this.w/2,-this.h/2,this.w,this.h);l.closePath(),l.restore()},n.prototype.animate=function(){if(l.fillStyle="grey",l.beginPath(),l.strokeRect(this.x,this.y,this.w,this.h),l.font="13px arial",l.textAlign="center",l.closePath(),this.particles.length<this.number){var t=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),n=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles.push(new e(t,n,this.text))}this.particles.length>this.number&&(this.particles.length=this.number);for(var i=0;i<this.particles.length;i++){var r=this.particles[i];if(r.update(),r.y>p||r.y<-100||r.x>f+100||r.x<-100&&this.recycle){var o=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),a=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles[i]=new e(o,a,this.text)}}};var y=new n(0,0,f,0,o);i(),r()}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r;var o=n(2),s=i(o)},function(t,e){"use strict";function n(t,e,n){return(t-e)/(n-e)}function i(t,e,n){return(n-e)*t+e}function r(t,e,r,o,s){return i(n(t,e,r),o,s)}function o(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 a(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}function h(t,e){return s(t,e)<=t.radius+e.radius}function u(t,e,n){return a(t,e,n.x,n.y)<n.radius}function c(t,e,n){return t>=Math.min(e,n)&&t<=Math.max(e,n)}function l(t,e,n){return c(t,n.x,n.x+n.width)&&c(e,n.y,n.y+n.height)}function f(t,e,n,i){return Math.max(t,e)>=Math.min(n,i)&&Math.min(t,e)<=Math.max(n,i)}function p(t,e){return f(t.x,t.x+t.width,e.x,e.x+e.width)&&f(t.y,t.y+t.height,e.y,e.y+e.height)}function d(t){return t/180*Math.PI}function y(t){return 180*t/Math.PI}function m(t,e){return t+Math.random()*(e-t)}function g(t,e){return Math.floor(t+Math.random()*(e-t+1))}Object.defineProperty(e,"__esModule",{value:!0}),e.norm=n,e.lerp=i,e.map=r,e.clamp=o,e.distance=s,e.distanceXY=a,e.circleCollision=h,e.circlePointCollision=u,e.inRange=c,e.pointInRect=l,e.rangeIntersect=f,e.rectIntersect=p,e.degreesToRads=d,e.radsToDegrees=y,e.randomRange=m,e.randomInt=g},function(e,n){e.exports=t}])});
!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]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="/lib",e(0)}([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(3),u=i(h),c=n(1),l=i(c),p=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(){(0,l.default)(this.refs.confetti,this.props.numberOfPieces,this.props.friction,this.props.wind,this.props.gravity,this.props.colors)}},{key:"render",value:function(){var t=Object.assign({},{zIndex:2,position:"absolute",top:0,left:0,width:this.props.width,height:this.props.height,pointerEvents:"none",WebkitPointerEvents:"none",MozPointerEvents:"none"},this.props.style);return u.default.createElement("canvas",{width:this.props.width,height:this.props.height,ref:"confetti",style:t})}}]),e}(u.default.Component);p.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)},p.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"]},e.default=p},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(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=c[Math.floor(Math.random()*c.length)],this.rotateY=s.randomRange(0,1)}function n(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 i(){0===y.type?(y.type=1,y.x=f/2,y.y=d/2,y.w=0):(y.type=0,y.x=1,y.w=f,y.y=0)}function r(){y.number=o,p.fillStyle="white",p.clearRect(0,0,f,d),y.animate(),requestAnimationFrame(r)}var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.99,h=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.1,c=arguments[5],l=t,p=l.getContext("2d"),f=window.innerWidth||Math.max(document.documentElement.clientWidth,document.body.clientWidth),d=window.innerHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight);l.width=f,l.height=d,e.prototype.update=function(){if(this.x+=this.vx,this.y+=this.vy,this.vy+=u,this.vx+=h,this.vx*=a,this.vy*=a,this.radius-=.02,this.rotateY<1?this.rotateY+=.1:this.rotateY=-1,this.angle+=this.anglespin,p.save(),p.translate(this.x,this.y),p.rotate(this.angle),p.scale(1,this.rotateY),p.rotate(this.angle),p.beginPath(),p.fillStyle=this.color,p.strokeStyle=this.color,p.lineCap="round",p.lineWidth=2,0===this.type)p.beginPath(),p.arc(0,0,this.r,0,2*Math.PI),p.fill();else if(2===this.type){p.beginPath();for(var t=0;t<22;t++){var e=.5*t,n=(.2+1.5*e)*Math.cos(e),i=(.2+1.5*e)*Math.sin(e);p.lineTo(n,i)}p.stroke()}else 1===this.type&&p.fillRect(-this.w/2,-this.h/2,this.w,this.h);p.closePath(),p.restore()},n.prototype.animate=function(){if(p.fillStyle="grey",p.beginPath(),p.strokeRect(this.x,this.y,this.w,this.h),p.font="13px arial",p.textAlign="center",p.closePath(),this.particles.length<this.number){var t=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),n=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles.push(new e(t,n,this.text))}this.particles.length>this.number&&(this.particles.length=this.number);for(var i=0;i<this.particles.length;i++){var r=this.particles[i];if(r.update(),r.y>d||r.y<-100||r.x>f+100||r.x<-100&&this.recycle){var o=s.clamp(s.randomRange(this.x,this.w+this.x),this.x,this.w+this.x),a=s.clamp(s.randomRange(this.y,this.h+this.y),this.y,this.h+this.y);this.particles[i]=new e(o,a,this.text)}}};var y=new n(0,0,f,0,o);i(),r()}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var o=n(2),s=i(o)},function(t,e){"use strict";function n(t,e,n){return(t-e)/(n-e)}function i(t,e,n){return(n-e)*t+e}function r(t,e,r,o,s){return i(n(t,e,r),o,s)}function o(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 a(t,e,n,i){var r=n-t,o=i-e;return Math.sqrt(r*r+o*o)}function h(t,e){return s(t,e)<=t.radius+e.radius}function u(t,e,n){return a(t,e,n.x,n.y)<n.radius}function c(t,e,n){return t>=Math.min(e,n)&&t<=Math.max(e,n)}function l(t,e,n){return c(t,n.x,n.x+n.width)&&c(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 f(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 d(t){return t/180*Math.PI}function y(t){return 180*t/Math.PI}function m(t,e){return t+Math.random()*(e-t)}function g(t,e){return Math.floor(t+Math.random()*(e-t+1))}Object.defineProperty(e,"__esModule",{value:!0}),e.norm=n,e.lerp=i,e.map=r,e.clamp=o,e.distance=s,e.distanceXY=a,e.circleCollision=h,e.circlePointCollision=u,e.inRange=c,e.pointInRect=l,e.rangeIntersect=p,e.rectIntersect=f,e.degreesToRads=d,e.radsToDegrees=y,e.randomRange=m,e.randomInt=g},function(e,n){e.exports=t}])});
{
"name": "react-confetti",
"version": "1.0.2",
"version": "1.0.3",
"description": "React component to draw confetti for your party.",

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

@@ -6,2 +6,7 @@ # react-confetti

[![demogif][2]][1]
[1]: http://alampros.github.com/react-confetti
[2]: http://alampros.github.io/react-confetti/assets/confetti-demo.gif (demo gif)
## Install

@@ -42,2 +47,3 @@

`gravity` | `Number` | 0.1 |
`colors` | `Array` of `String` | `['#f44336'`</br>`'#e91e63'`</br>`'#9c27b0'`</br>`'#673ab7'`</br>`'#3f51b5'`</br>`'#2196f3'`</br>`'#03a9f4'`</br>`'#00bcd4'`</br>`'#009688'`</br>`'#4CAF50'`</br>`'#8BC34A'`</br>`'#CDDC39'`</br>`'#FFEB3B'`</br>`'#FFC107'`</br>`'#FF9800'`</br>`'#FF5722'`</br>`'#795548']`</br> | All available Colors for the confetti pieces
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