canvas-confetti
Advanced tools
Comparing version
{ | ||
"name": "canvas-confetti", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "performant confetti animation in the browser", | ||
@@ -5,0 +5,0 @@ "main": "src/confetti.js", |
# [](https://github.com/catdad/canvas-confetti/) | ||
[![travis][travis.svg]][travis.link] | ||
[![github actions ci][ci.svg]][ci.link] | ||
[![jsdelivr][jsdelivr.svg]][jsdelivr.link] | ||
@@ -8,4 +8,4 @@ [![npm-downloads][npm-downloads.svg]][npm.link] | ||
[travis.svg]: https://travis-ci.org/catdad/canvas-confetti.svg?branch=master | ||
[travis.link]: https://travis-ci.org/catdad/canvas-confetti | ||
[ci.svg]: https://github.com/catdad/canvas-confetti/actions/workflows/ci.yml/badge.svg | ||
[ci.link]: https://github.com/catdad/canvas-confetti/actions/workflows/ci.yml?query=branch%3Amaster | ||
[jsdelivr.svg]: https://data.jsdelivr.com/v1/package/npm/canvas-confetti/badge?style=rounded | ||
@@ -34,3 +34,3 @@ [jsdelivr.link]: https://www.jsdelivr.com/package/npm/canvas-confetti | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.4.0/dist/confetti.browser.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.0/dist/confetti.browser.min.js"></script> | ||
``` | ||
@@ -94,7 +94,7 @@ | ||
_**Important: If you use `useWorker: true`, I own your canvas now. It's mine now and I can do whatever I want with it (don't worry... I'll just put confetti inside it, I promise). You must not try to use the canvas in any way (other than I guess removing it from the DOM), as it will throw an error. When using workers for rendering, control of the canvas must be transfered to the web worker, preventing any usage of that canvas on the main thread. If you must manipulate the canvas in any way, do not use this option.**_ | ||
_**Important: If you use `useWorker: true`, I own your canvas now. It's mine now and I can do whatever I want with it (don't worry... I'll just put confetti inside it, I promise). You must not try to use the canvas in any way (other than I guess removing it from the DOM), as it will throw an error. When using workers for rendering, control of the canvas must be transferred to the web worker, preventing any usage of that canvas on the main thread. If you must manipulate the canvas in any way, do not use this option.**_ | ||
```javascript | ||
var myCanvas = document.createElement('canvas'); | ||
document.appendChild(myCanvas); | ||
document.body.appendChild(myCanvas); | ||
@@ -127,3 +127,3 @@ var myConfetti = confetti.create(myCanvas, { | ||
var myCanvas = document.createElement('canvas'); | ||
document.appendChild(myCanvas); | ||
document.body.appendChild(myCanvas); | ||
@@ -130,0 +130,0 @@ var myConfetti = confetti.create(myCanvas, { resize: true }); |
@@ -290,5 +290,6 @@ (function main(global, module, isWorker, workerSize) { | ||
wobble: Math.random() * 10, | ||
wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05), | ||
velocity: (opts.startVelocity * 0.5) + (Math.random() * opts.startVelocity), | ||
angle2D: -radAngle + ((0.5 * radSpread) - (Math.random() * radSpread)), | ||
tiltAngle: Math.random() * Math.PI, | ||
tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI, | ||
color: opts.color, | ||
@@ -300,3 +301,3 @@ shape: opts.shape, | ||
drift: opts.drift, | ||
random: Math.random() + 5, | ||
random: Math.random() + 2, | ||
tiltSin: 0, | ||
@@ -315,3 +316,3 @@ tiltCos: 0, | ||
fetti.y += Math.sin(fetti.angle2D) * fetti.velocity + fetti.gravity; | ||
fetti.wobble += 0.1; | ||
fetti.wobble += fetti.wobbleSpeed; | ||
fetti.velocity *= fetti.decay; | ||
@@ -321,3 +322,3 @@ fetti.tiltAngle += 0.1; | ||
fetti.tiltCos = Math.cos(fetti.tiltAngle); | ||
fetti.random = Math.random() + 5; | ||
fetti.random = Math.random() + 2; | ||
fetti.wobbleX = fetti.x + ((10 * fetti.scalar) * Math.cos(fetti.wobble)); | ||
@@ -583,3 +584,17 @@ fetti.wobbleY = fetti.y + ((10 * fetti.scalar) * Math.sin(fetti.wobble)); | ||
module.exports = confettiCannon(null, { useWorker: true, resize: true }); | ||
// Make default export lazy to defer worker creation until called. | ||
var defaultFire; | ||
function getDefaultFire() { | ||
if (!defaultFire) { | ||
defaultFire = confettiCannon(null, { useWorker: true, resize: true }); | ||
} | ||
return defaultFire; | ||
} | ||
module.exports = function() { | ||
return getDefaultFire().apply(this, arguments); | ||
}; | ||
module.exports.reset = function() { | ||
getDefaultFire().reset(); | ||
}; | ||
module.exports.create = confettiCannon; | ||
@@ -586,0 +601,0 @@ }((function () { |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30649
-51.33%4
-33.33%504
-65.99%1
Infinity%1
Infinity%