New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

confetti-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confetti-react - npm Package Compare versions

Comparing version 2.5.0 to 2.6.0

6

dist/confetti-react.cjs.development.js

@@ -435,7 +435,3 @@ 'use strict';

for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
_this = _Component.call.apply(_Component, [this, props].concat(rest)) || this;
_this = _Component.call(this, props) || this;
_this.canvas = React__default.createRef();

@@ -442,0 +438,0 @@ _this.canvas = props.canvasRef || ref;

2

dist/confetti-react.cjs.production.min.js

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

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,i,n=require("react"),o=t(n),r=t(require("tween-functions"));function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return t+Math.random()*(e-t)}!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Strip=2]="Strip"}(e||(e={})),function(t){t[t.Positive=1]="Positive",t[t.Negative=-1]="Negative"}(i||(i={}));var h=function(){function t(t,e,n,o){this.getOptions=e;var r=this.getOptions(),s=r.colors,a=r.initialVelocityX,h=r.initialVelocityY;this.context=t,this.x=n,this.y=o,this.w=c(5,20),this.h=c(5,20),this.radius=c(5,10),this.vx=c(-a,a),this.vy=c(-h,0),this.shape=Math.floor(0+3*Math.random()),this.angle=c(0,360)*Math.PI/180,this.angularSpin=c(-.2,.2),this.color=s[Math.floor(Math.random()*s.length)],this.rotateY=c(0,1),this.rotationDirection=c(0,1)?i.Positive:i.Negative}return t.prototype.update=function(){var t=this.getOptions(),n=t.gravity,o=t.wind,r=t.friction,s=t.opacity,a=t.drawShape;if(this.x+=this.vx,this.y+=this.vy,this.vy+=n,this.vx+=o,this.vx*=r,this.vy*=r,this.rotateY>=1&&this.rotationDirection===i.Positive?this.rotationDirection=i.Negative:this.rotateY<=-1&&this.rotationDirection===i.Negative&&(this.rotationDirection=i.Positive),this.rotateY+=.1*this.rotationDirection,this.angle+=this.angularSpin,this.context.save(),this.context.translate(this.x,this.y),this.context.rotate(this.angle),this.context.scale(1,this.rotateY),this.context.rotate(this.angle),this.context.beginPath(),this.context.fillStyle=this.color,this.context.strokeStyle=this.color,this.context.globalAlpha=s,this.context.lineCap="round",this.context.lineWidth=2,a&&"function"==typeof a)a.call(this,this.context);else switch(this.shape){case e.Circle:this.context.beginPath(),this.context.arc(0,0,this.radius,0,2*Math.PI),this.context.fill();break;case e.Square:this.context.fillRect(-this.w/2,-this.h/2,this.w,this.h);break;case e.Strip:this.context.fillRect(-this.w/6,-this.h/2,this.w/3,this.h);break;default:throw new Error("Unknown type in Particle.ts")}this.context.closePath(),this.context.restore()},t}(),l=function(t,e){var i=this;this.x=0,this.y=0,this.w=0,this.h=0,this.lastNumberOfPieces=0,this.tweenInitTime=Date.now(),this.particles=[],this.particlesGenerated=0,this.removeParticleAt=function(t){i.particles.splice(t,1)},this.getParticle=function(){var t=c(i.x,i.w+i.x),e=c(i.y,i.h+i.y);return new h(i.context,i.getOptions,t,e)},this.animate=function(){var t=i.canvas,e=i.context,n=i.particlesGenerated,o=i.lastNumberOfPieces,r=i.getOptions(),s=r.recycle,a=r.numberOfPieces,c=r.debug,h=r.tweenFunction,l=r.tweenDuration;if(!r.run)return!1;var u=i.particles.length,f=s?u:n,p=Date.now();if(f<a){o!==a&&(i.tweenInitTime=p,i.lastNumberOfPieces=a);for(var v=i.tweenInitTime,d=h(p-v>l?l:Math.max(0,p-v),f,a,l),g=Math.round(d-f),y=0;y<g;y+=1)i.particles.push(i.getParticle());i.particlesGenerated+=g}return c&&(e.font="12px sans-serif",e.fillStyle="#333",e.textAlign="right",e.fillText("Particles: "+u,t.width-10,t.height-20)),i.particles.forEach((function(e,n){e.update(),(e.y>t.height||e.y<-100||e.x>t.width+100||e.x<-100)&&(s&&f<=a?i.particles[n]=i.getParticle():i.removeParticleAt(n))})),u>0||f<a},this.canvas=t;var n=this.canvas.getContext("2d");if(!n)throw new Error("Could not get canvas context");this.context=n,this.getOptions=e},u={width:"undefined"!=typeof window?window.innerWidth:300,height:"undefined"!=typeof window?window.innerHeight:200,numberOfPieces:200,friction:.99,wind:0,gravity:.1,initialVelocityX:4,initialVelocityY:10,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1,debug:!1,tweenFunction:r.easeInOutQuad,tweenDuration:5e3,recycle:!0,run:!0},f=function(){function t(t,e){var i=this;this.setOptionsWithDefaults=function(t){i._options=s({},{confettiSource:{x:0,y:0,w:i.canvas.width,h:0}},u,t),Object.assign(i,t.confettiSource)},this.update=function(){var t=i.options,e=t.onConfettiComplete,n=i.canvas,o=i.context;t.run&&(o.fillStyle="white",o.clearRect(0,0,n.width,n.height)),i.generator.animate()?i.rafId=requestAnimationFrame(i.update):(e&&"function"==typeof e&&i.generator.particlesGenerated>0&&e.call(i,i),i._options.run=!1)},this.reset=function(){i.generator&&i.generator.particlesGenerated>0&&(i.generator.particlesGenerated=0,i.generator.particles=[],i.generator.lastNumberOfPieces=0)},this.stop=function(){i.options={run:!1},i.rafId&&(cancelAnimationFrame(i.rafId),i.rafId=void 0)},this.canvas=t;var n=this.canvas.getContext("2d");if(!n)throw new Error("Could not get canvas context");this.context=n,this.generator=new l(this.canvas,(function(){return i.options})),this.options=e,this.update()}var e;return(e=[{key:"options",get:function(){return this._options},set:function(t){var e=this._options&&this._options.run,i=this._options&&this._options.recycle;this.setOptionsWithDefaults(t),this.generator&&(Object.assign(this.generator,this.options.confettiSource),"boolean"==typeof t.recycle&&t.recycle&&!1===i&&(this.generator.lastNumberOfPieces=this.generator.particles.length)),"boolean"==typeof t.run&&t.run&&!1===e&&this.update()}}])&&function(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,e),t}(),p=o.createRef();function v(t){var e={},i={},n=[].concat(Object.keys(u),["confettiSource","drawShape","onConfettiComplete"]),o=["canvasRef"];return Object.keys(t).forEach((function(r){var s=t[r];n.includes(r)?e[r]=s:o.includes(r)?o[r]=s:i[r]=s})),[e,i,{}]}var d=function(t){var e,i;function n(e){for(var i,n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return(i=t.call.apply(t,[this,e].concat(r))||this).canvas=o.createRef(),i.canvas=e.canvasRef||p,i}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,a(e,i);var r=n.prototype;return r.componentDidMount=function(){if(this.canvas.current){var t=v(this.props)[0];this.confetti=new f(this.canvas.current,t)}},r.componentDidUpdate=function(){var t=v(this.props)[0];this.confetti&&(this.confetti.options=t)},r.componentWillUnmount=function(){this.confetti&&this.confetti.stop(),this.confetti=void 0},r.render=function(){var t=v(this.props),e=t[0],i=t[1],n=s({zIndex:2,position:"absolute",pointerEvents:"none",top:0,left:0,bottom:0,right:0},i.style);return o.createElement("canvas",Object.assign({width:e.width,height:e.height,ref:this.canvas},i,{style:n}))},n}(n.Component);d.defaultProps=s({},u),d.displayName="ConfettiReact";var g=o.forwardRef((function(t,e){return o.createElement(d,Object.assign({canvasRef:p},t))}));exports.Index=g,exports.default=g;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e,i,n=require("react"),o=t(n),r=t(require("tween-functions"));function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return t+Math.random()*(e-t)}!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Strip=2]="Strip"}(e||(e={})),function(t){t[t.Positive=1]="Positive",t[t.Negative=-1]="Negative"}(i||(i={}));var h=function(){function t(t,e,n,o){this.getOptions=e;var r=this.getOptions(),s=r.colors,a=r.initialVelocityX,h=r.initialVelocityY;this.context=t,this.x=n,this.y=o,this.w=c(5,20),this.h=c(5,20),this.radius=c(5,10),this.vx=c(-a,a),this.vy=c(-h,0),this.shape=Math.floor(0+3*Math.random()),this.angle=c(0,360)*Math.PI/180,this.angularSpin=c(-.2,.2),this.color=s[Math.floor(Math.random()*s.length)],this.rotateY=c(0,1),this.rotationDirection=c(0,1)?i.Positive:i.Negative}return t.prototype.update=function(){var t=this.getOptions(),n=t.gravity,o=t.wind,r=t.friction,s=t.opacity,a=t.drawShape;if(this.x+=this.vx,this.y+=this.vy,this.vy+=n,this.vx+=o,this.vx*=r,this.vy*=r,this.rotateY>=1&&this.rotationDirection===i.Positive?this.rotationDirection=i.Negative:this.rotateY<=-1&&this.rotationDirection===i.Negative&&(this.rotationDirection=i.Positive),this.rotateY+=.1*this.rotationDirection,this.angle+=this.angularSpin,this.context.save(),this.context.translate(this.x,this.y),this.context.rotate(this.angle),this.context.scale(1,this.rotateY),this.context.rotate(this.angle),this.context.beginPath(),this.context.fillStyle=this.color,this.context.strokeStyle=this.color,this.context.globalAlpha=s,this.context.lineCap="round",this.context.lineWidth=2,a&&"function"==typeof a)a.call(this,this.context);else switch(this.shape){case e.Circle:this.context.beginPath(),this.context.arc(0,0,this.radius,0,2*Math.PI),this.context.fill();break;case e.Square:this.context.fillRect(-this.w/2,-this.h/2,this.w,this.h);break;case e.Strip:this.context.fillRect(-this.w/6,-this.h/2,this.w/3,this.h);break;default:throw new Error("Unknown type in Particle.ts")}this.context.closePath(),this.context.restore()},t}(),l=function(t,e){var i=this;this.x=0,this.y=0,this.w=0,this.h=0,this.lastNumberOfPieces=0,this.tweenInitTime=Date.now(),this.particles=[],this.particlesGenerated=0,this.removeParticleAt=function(t){i.particles.splice(t,1)},this.getParticle=function(){var t=c(i.x,i.w+i.x),e=c(i.y,i.h+i.y);return new h(i.context,i.getOptions,t,e)},this.animate=function(){var t=i.canvas,e=i.context,n=i.particlesGenerated,o=i.lastNumberOfPieces,r=i.getOptions(),s=r.recycle,a=r.numberOfPieces,c=r.debug,h=r.tweenFunction,l=r.tweenDuration;if(!r.run)return!1;var u=i.particles.length,f=s?u:n,p=Date.now();if(f<a){o!==a&&(i.tweenInitTime=p,i.lastNumberOfPieces=a);for(var v=i.tweenInitTime,d=h(p-v>l?l:Math.max(0,p-v),f,a,l),g=Math.round(d-f),y=0;y<g;y+=1)i.particles.push(i.getParticle());i.particlesGenerated+=g}return c&&(e.font="12px sans-serif",e.fillStyle="#333",e.textAlign="right",e.fillText("Particles: "+u,t.width-10,t.height-20)),i.particles.forEach((function(e,n){e.update(),(e.y>t.height||e.y<-100||e.x>t.width+100||e.x<-100)&&(s&&f<=a?i.particles[n]=i.getParticle():i.removeParticleAt(n))})),u>0||f<a},this.canvas=t;var n=this.canvas.getContext("2d");if(!n)throw new Error("Could not get canvas context");this.context=n,this.getOptions=e},u={width:"undefined"!=typeof window?window.innerWidth:300,height:"undefined"!=typeof window?window.innerHeight:200,numberOfPieces:200,friction:.99,wind:0,gravity:.1,initialVelocityX:4,initialVelocityY:10,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1,debug:!1,tweenFunction:r.easeInOutQuad,tweenDuration:5e3,recycle:!0,run:!0},f=function(){function t(t,e){var i=this;this.setOptionsWithDefaults=function(t){i._options=s({},{confettiSource:{x:0,y:0,w:i.canvas.width,h:0}},u,t),Object.assign(i,t.confettiSource)},this.update=function(){var t=i.options,e=t.onConfettiComplete,n=i.canvas,o=i.context;t.run&&(o.fillStyle="white",o.clearRect(0,0,n.width,n.height)),i.generator.animate()?i.rafId=requestAnimationFrame(i.update):(e&&"function"==typeof e&&i.generator.particlesGenerated>0&&e.call(i,i),i._options.run=!1)},this.reset=function(){i.generator&&i.generator.particlesGenerated>0&&(i.generator.particlesGenerated=0,i.generator.particles=[],i.generator.lastNumberOfPieces=0)},this.stop=function(){i.options={run:!1},i.rafId&&(cancelAnimationFrame(i.rafId),i.rafId=void 0)},this.canvas=t;var n=this.canvas.getContext("2d");if(!n)throw new Error("Could not get canvas context");this.context=n,this.generator=new l(this.canvas,(function(){return i.options})),this.options=e,this.update()}var e;return(e=[{key:"options",get:function(){return this._options},set:function(t){var e=this._options&&this._options.run,i=this._options&&this._options.recycle;this.setOptionsWithDefaults(t),this.generator&&(Object.assign(this.generator,this.options.confettiSource),"boolean"==typeof t.recycle&&t.recycle&&!1===i&&(this.generator.lastNumberOfPieces=this.generator.particles.length)),"boolean"==typeof t.run&&t.run&&!1===e&&this.update()}}])&&function(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}(t.prototype,e),t}(),p=o.createRef();function v(t){var e={},i={},n=[].concat(Object.keys(u),["confettiSource","drawShape","onConfettiComplete"]),o=["canvasRef"];return Object.keys(t).forEach((function(r){var s=t[r];n.includes(r)?e[r]=s:o.includes(r)?o[r]=s:i[r]=s})),[e,i,{}]}var d=function(t){var e,i;function n(e){var i;return(i=t.call(this,e)||this).canvas=o.createRef(),i.canvas=e.canvasRef||p,i}i=t,(e=n).prototype=Object.create(i.prototype),e.prototype.constructor=e,a(e,i);var r=n.prototype;return r.componentDidMount=function(){if(this.canvas.current){var t=v(this.props)[0];this.confetti=new f(this.canvas.current,t)}},r.componentDidUpdate=function(){var t=v(this.props)[0];this.confetti&&(this.confetti.options=t)},r.componentWillUnmount=function(){this.confetti&&this.confetti.stop(),this.confetti=void 0},r.render=function(){var t=v(this.props),e=t[0],i=t[1],n=s({zIndex:2,position:"absolute",pointerEvents:"none",top:0,left:0,bottom:0,right:0},i.style);return o.createElement("canvas",Object.assign({width:e.width,height:e.height,ref:this.canvas},i,{style:n}))},n}(n.Component);d.defaultProps=s({},u),d.displayName="ConfettiReact";var g=o.forwardRef((function(t,e){return o.createElement(d,Object.assign({canvasRef:p},t))}));exports.Index=g,exports.default=g;
//# sourceMappingURL=confetti-react.cjs.production.min.js.map

@@ -428,7 +428,3 @@ import React, { Component } from 'react';

for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
_this = _Component.call.apply(_Component, [this, props].concat(rest)) || this;
_this = _Component.call(this, props) || this;
_this.canvas = React.createRef();

@@ -435,0 +431,0 @@ _this.canvas = props.canvasRef || ref;

{
"name": "confetti-react",
"version": "2.5.0",
"version": "2.6.0",
"description": "React component to draw confetti for your party.",

@@ -48,3 +48,3 @@ "main": "dist/index.js",

"peerDependencies": {
"react": "^16.3.0 || ^17.0.0"
"react": "^16.3.0 || ^17.0.0 || ^18.3.1"
},

@@ -51,0 +51,0 @@ "dependencies": {

@@ -1,4 +0,4 @@

# This is a fork
This is a fork of [react-confetti](https://github.com/alampros/react-confetti) which was created when that library was unsupported and the latest release was completely broken. It is my understanding that the original library is once again actively maintained. This fork has cleaner builds, but is not as active.
This is a fork of [react-confetti](https://github.com/alampros/react-confetti) from a time when the library was unsupported and the latest release was completely broken. It is my understanding that the original library is once again actively maintained.
For live examples and demo's of this code, you can reference the [react-confetti live documentation](https://alampros.github.io/react-confetti/).

@@ -5,0 +5,0 @@ # confetti-react

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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