Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tsparticles/updater-rotate

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsparticles/updater-rotate - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0

50

browser/RotateUpdater.js

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

import { getRandom, getRangeValue, } from "@tsparticles/engine";
import { degToRad, getRandom, getRangeValue, updateAnimation, } from "@tsparticles/engine";
import { Rotate } from "./Options/Classes/Rotate.js";
function updateRotate(particle, delta) {
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
if (!rotate || !rotateOptions) {
return;
}
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
if (!rotateAnimation.enable) {
return;
}
switch (rotate.status) {
case "increasing":
rotate.value += speed;
if (rotate.value > max) {
rotate.value -= max;
}
break;
case "decreasing":
default:
rotate.value -= speed;
if (rotate.value < 0) {
rotate.value += max;
}
break;
}
if (rotate.velocity && decay !== 1) {
rotate.velocity *= decay;
}
}
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
export class RotateUpdater {

@@ -42,3 +15,5 @@ constructor(container) {

enable: rotateOptions.animation.enable,
value: (getRangeValue(rotateOptions.value) * Math.PI) / 180,
value: degToRad(getRangeValue(rotateOptions.value)),
min: 0,
max: doublePI,
};

@@ -48,4 +23,4 @@ particle.pathRotation = rotateOptions.path;

if (rotateDirection === "random") {
const index = Math.floor(getRandom() * 2);
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
const index = Math.floor(getRandom() * double), minIndex = 0;
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
}

@@ -63,5 +38,5 @@ switch (rotateDirection) {

if (rotateAnimation.enable) {
particle.rotate.decay = 1 - getRangeValue(rotateAnimation.decay);
particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
particle.rotate.velocity =
(getRangeValue(rotateAnimation.speed) / 360) * this.container.retina.reduceFactor;
(getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
if (!rotateAnimation.sync) {

@@ -92,5 +67,8 @@ particle.rotate.velocity *= getRandom();

}
updateRotate(particle, delta);
particle.rotation = particle.rotate?.value ?? 0;
if (!particle.rotate) {
return;
}
updateAnimation(particle, particle.rotate, false, "none", delta);
particle.rotation = particle.rotate.value;
}
}

@@ -6,30 +6,3 @@ "use strict";

const Rotate_js_1 = require("./Options/Classes/Rotate.js");
function updateRotate(particle, delta) {
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
if (!rotate || !rotateOptions) {
return;
}
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
if (!rotateAnimation.enable) {
return;
}
switch (rotate.status) {
case "increasing":
rotate.value += speed;
if (rotate.value > max) {
rotate.value -= max;
}
break;
case "decreasing":
default:
rotate.value -= speed;
if (rotate.value < 0) {
rotate.value += max;
}
break;
}
if (rotate.velocity && decay !== 1) {
rotate.velocity *= decay;
}
}
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
class RotateUpdater {

@@ -46,3 +19,5 @@ constructor(container) {

enable: rotateOptions.animation.enable,
value: ((0, engine_1.getRangeValue)(rotateOptions.value) * Math.PI) / 180,
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(rotateOptions.value)),
min: 0,
max: doublePI,
};

@@ -52,4 +27,4 @@ particle.pathRotation = rotateOptions.path;

if (rotateDirection === "random") {
const index = Math.floor((0, engine_1.getRandom)() * 2);
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
}

@@ -67,5 +42,5 @@ switch (rotateDirection) {

if (rotateAnimation.enable) {
particle.rotate.decay = 1 - (0, engine_1.getRangeValue)(rotateAnimation.decay);
particle.rotate.decay = identity - (0, engine_1.getRangeValue)(rotateAnimation.decay);
particle.rotate.velocity =
((0, engine_1.getRangeValue)(rotateAnimation.speed) / 360) * this.container.retina.reduceFactor;
((0, engine_1.getRangeValue)(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
if (!rotateAnimation.sync) {

@@ -96,6 +71,9 @@ particle.rotate.velocity *= (0, engine_1.getRandom)();

}
updateRotate(particle, delta);
particle.rotation = particle.rotate?.value ?? 0;
if (!particle.rotate) {
return;
}
(0, engine_1.updateAnimation)(particle, particle.rotate, false, "none", delta);
particle.rotation = particle.rotate.value;
}
}
exports.RotateUpdater = RotateUpdater;

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

import { getRandom, getRangeValue, } from "@tsparticles/engine";
import { degToRad, getRandom, getRangeValue, updateAnimation, } from "@tsparticles/engine";
import { Rotate } from "./Options/Classes/Rotate.js";
function updateRotate(particle, delta) {
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
if (!rotate || !rotateOptions) {
return;
}
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
if (!rotateAnimation.enable) {
return;
}
switch (rotate.status) {
case "increasing":
rotate.value += speed;
if (rotate.value > max) {
rotate.value -= max;
}
break;
case "decreasing":
default:
rotate.value -= speed;
if (rotate.value < 0) {
rotate.value += max;
}
break;
}
if (rotate.velocity && decay !== 1) {
rotate.velocity *= decay;
}
}
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
export class RotateUpdater {

@@ -42,3 +15,5 @@ constructor(container) {

enable: rotateOptions.animation.enable,
value: (getRangeValue(rotateOptions.value) * Math.PI) / 180,
value: degToRad(getRangeValue(rotateOptions.value)),
min: 0,
max: doublePI,
};

@@ -48,4 +23,4 @@ particle.pathRotation = rotateOptions.path;

if (rotateDirection === "random") {
const index = Math.floor(getRandom() * 2);
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
const index = Math.floor(getRandom() * double), minIndex = 0;
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
}

@@ -63,5 +38,5 @@ switch (rotateDirection) {

if (rotateAnimation.enable) {
particle.rotate.decay = 1 - getRangeValue(rotateAnimation.decay);
particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
particle.rotate.velocity =
(getRangeValue(rotateAnimation.speed) / 360) * this.container.retina.reduceFactor;
(getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
if (!rotateAnimation.sync) {

@@ -92,5 +67,8 @@ particle.rotate.velocity *= getRandom();

}
updateRotate(particle, delta);
particle.rotation = particle.rotate?.value ?? 0;
if (!particle.rotate) {
return;
}
updateAnimation(particle, particle.rotate, false, "none", delta);
particle.rotation = particle.rotate.value;
}
}
{
"name": "@tsparticles/updater-rotate",
"version": "3.0.3",
"version": "3.1.0",
"description": "tsParticles particles rotate updater",

@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org",

"dependencies": {
"@tsparticles/engine": "^3.0.3"
"@tsparticles/engine": "^3.1.0"
},

@@ -93,0 +93,0 @@ "publishConfig": {

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v3.0.3
* v3.1.0
*/

@@ -155,34 +155,6 @@ (function webpackUniversalModuleDefinition(root, factory) {

function updateRotate(particle, delta) {
const rotate = particle.rotate,
rotateOptions = particle.options.rotate;
if (!rotate || !rotateOptions) {
return;
}
const rotateAnimation = rotateOptions.animation,
speed = (rotate.velocity ?? 0) * delta.factor,
max = 2 * Math.PI,
decay = rotate.decay ?? 1;
if (!rotateAnimation.enable) {
return;
}
switch (rotate.status) {
case "increasing":
rotate.value += speed;
if (rotate.value > max) {
rotate.value -= max;
}
break;
case "decreasing":
default:
rotate.value -= speed;
if (rotate.value < 0) {
rotate.value += max;
}
break;
}
if (rotate.velocity && decay !== 1) {
rotate.velocity *= decay;
}
}
const RotateUpdater_double = 2,
doublePI = Math.PI * RotateUpdater_double,
identity = 1,
doublePIDeg = 360;
class RotateUpdater {

@@ -199,3 +171,5 @@ constructor(container) {

enable: rotateOptions.animation.enable,
value: (0,engine_root_window_.getRangeValue)(rotateOptions.value) * Math.PI / 180
value: (0,engine_root_window_.degToRad)((0,engine_root_window_.getRangeValue)(rotateOptions.value)),
min: 0,
max: doublePI
};

@@ -205,4 +179,5 @@ particle.pathRotation = rotateOptions.path;

if (rotateDirection === "random") {
const index = Math.floor((0,engine_root_window_.getRandom)() * 2);
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
const index = Math.floor((0,engine_root_window_.getRandom)() * RotateUpdater_double),
minIndex = 0;
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
}

@@ -220,4 +195,4 @@ switch (rotateDirection) {

if (rotateAnimation.enable) {
particle.rotate.decay = 1 - (0,engine_root_window_.getRangeValue)(rotateAnimation.decay);
particle.rotate.velocity = (0,engine_root_window_.getRangeValue)(rotateAnimation.speed) / 360 * this.container.retina.reduceFactor;
particle.rotate.decay = identity - (0,engine_root_window_.getRangeValue)(rotateAnimation.decay);
particle.rotate.velocity = (0,engine_root_window_.getRangeValue)(rotateAnimation.speed) / doublePIDeg * this.container.retina.reduceFactor;
if (!rotateAnimation.sync) {

@@ -248,4 +223,7 @@ particle.rotate.velocity *= (0,engine_root_window_.getRandom)();

}
updateRotate(particle, delta);
particle.rotation = particle.rotate?.value ?? 0;
if (!particle.rotate) {
return;
}
(0,engine_root_window_.updateAnimation)(particle, particle.rotate, false, "none", delta);
particle.rotation = particle.rotate.value;
}

@@ -252,0 +230,0 @@ }

/*! For license information please see tsparticles.updater.rotate.min.js.LICENSE.txt */
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var a="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in a)("object"==typeof exports?exports:e)[o]=a[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var i=a[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadRotateUpdater:()=>r});var e=o(533);class t{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,e.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class a extends e.ValueWithRandom{constructor(){super(),this.animation=new t,this.direction="clockwise",this.path=!1,this.value=0}load(e){e&&(super.load(e),void 0!==e.direction&&(this.direction=e.direction),this.animation.load(e.animation),void 0!==e.path&&(this.path=e.path))}}class i{constructor(e){this.container=e}init(t){const a=t.options.rotate;if(!a)return;t.rotate={enable:a.animation.enable,value:(0,e.getRangeValue)(a.value)*Math.PI/180},t.pathRotation=a.path;let o=a.direction;if("random"===o){o=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(o){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const n=a.animation;n.enable&&(t.rotate.decay=1-(0,e.getRangeValue)(n.decay),t.rotate.velocity=(0,e.getRangeValue)(n.speed)/360*this.container.retina.reduceFactor,n.sync||(t.rotate.velocity*=(0,e.getRandom)())),t.rotation=t.rotate.value}isEnabled(e){const t=e.options.rotate;return!!t&&(!e.destroyed&&!e.spawning&&t.animation.enable&&!t.path)}loadOptions(e,...t){e.rotate||(e.rotate=new a);for(const a of t)e.rotate.load(a?.rotate)}update(e,t){this.isEnabled(e)&&(!function(e,t){const a=e.rotate,o=e.options.rotate;if(!a||!o)return;const n=o.animation,i=(a.velocity??0)*t.factor,r=2*Math.PI,s=a.decay??1;n.enable&&("increasing"===a.status?(a.value+=i,a.value>r&&(a.value-=r)):(a.value-=i,a.value<0&&(a.value+=r)),a.velocity&&1!==s&&(a.velocity*=s))}(e,t),e.rotation=e.rotate?.value??0)}}async function r(e,t=!0){await e.addParticleUpdater("rotate",(e=>new i(e)),t)}})(),n})()));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var a in o)("object"==typeof exports?exports:e)[a]=o[a]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function a(e){var n=o[e];if(void 0!==n)return n.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{a.r(n),a.d(n,{loadRotateUpdater:()=>s});var e=a(533);class t{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,e.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class o extends e.ValueWithRandom{constructor(){super(),this.animation=new t,this.direction="clockwise",this.path=!1,this.value=0}load(e){e&&(super.load(e),void 0!==e.direction&&(this.direction=e.direction),this.animation.load(e.animation),void 0!==e.path&&(this.path=e.path))}}const i=2*Math.PI;class r{constructor(e){this.container=e}init(t){const o=t.options.rotate;if(!o)return;t.rotate={enable:o.animation.enable,value:(0,e.degToRad)((0,e.getRangeValue)(o.value)),min:0,max:i},t.pathRotation=o.path;let a=o.direction;if("random"===a){a=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(a){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const n=o.animation;n.enable&&(t.rotate.decay=1-(0,e.getRangeValue)(n.decay),t.rotate.velocity=(0,e.getRangeValue)(n.speed)/360*this.container.retina.reduceFactor,n.sync||(t.rotate.velocity*=(0,e.getRandom)())),t.rotation=t.rotate.value}isEnabled(e){const t=e.options.rotate;return!!t&&(!e.destroyed&&!e.spawning&&t.animation.enable&&!t.path)}loadOptions(e,...t){e.rotate||(e.rotate=new o);for(const o of t)e.rotate.load(o?.rotate)}update(t,o){this.isEnabled(t)&&t.rotate&&((0,e.updateAnimation)(t,t.rotate,!1,"none",o),t.rotation=t.rotate.value)}}async function s(e,t=!0){await e.addParticleUpdater("rotate",(e=>new r(e)),t)}})(),n})()));

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

/*! tsParticles Rotate Updater v3.0.3 by Matteo Bruni */
/*! tsParticles Rotate Updater v3.1.0 by Matteo Bruni */

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

import { type Container, type IDelta, type IParticleUpdater, type IParticleValueAnimation, type IParticlesOptions, type Particle, type ParticlesOptions, type RecursivePartial } from "@tsparticles/engine";
import { type Container, type IDelta, type IParticleNumericValueAnimation, type IParticleUpdater, type IParticlesOptions, type Particle, type ParticlesOptions, type RecursivePartial } from "@tsparticles/engine";
import type { IRotate } from "./Options/Interfaces/IRotate.js";

@@ -6,3 +6,3 @@ import { Rotate } from "./Options/Classes/Rotate.js";

options: RotateParticlesOptions;
rotate?: IParticleValueAnimation<number>;
rotate?: IParticleNumericValueAnimation;
};

@@ -9,0 +9,0 @@ type IRotateParticlesOptions = IParticlesOptions & {

@@ -15,30 +15,3 @@ (function (factory) {

const Rotate_js_1 = require("./Options/Classes/Rotate.js");
function updateRotate(particle, delta) {
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
if (!rotate || !rotateOptions) {
return;
}
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
if (!rotateAnimation.enable) {
return;
}
switch (rotate.status) {
case "increasing":
rotate.value += speed;
if (rotate.value > max) {
rotate.value -= max;
}
break;
case "decreasing":
default:
rotate.value -= speed;
if (rotate.value < 0) {
rotate.value += max;
}
break;
}
if (rotate.velocity && decay !== 1) {
rotate.velocity *= decay;
}
}
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
class RotateUpdater {

@@ -55,3 +28,5 @@ constructor(container) {

enable: rotateOptions.animation.enable,
value: ((0, engine_1.getRangeValue)(rotateOptions.value) * Math.PI) / 180,
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(rotateOptions.value)),
min: 0,
max: doublePI,
};

@@ -61,4 +36,4 @@ particle.pathRotation = rotateOptions.path;

if (rotateDirection === "random") {
const index = Math.floor((0, engine_1.getRandom)() * 2);
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
}

@@ -76,5 +51,5 @@ switch (rotateDirection) {

if (rotateAnimation.enable) {
particle.rotate.decay = 1 - (0, engine_1.getRangeValue)(rotateAnimation.decay);
particle.rotate.decay = identity - (0, engine_1.getRangeValue)(rotateAnimation.decay);
particle.rotate.velocity =
((0, engine_1.getRangeValue)(rotateAnimation.speed) / 360) * this.container.retina.reduceFactor;
((0, engine_1.getRangeValue)(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
if (!rotateAnimation.sync) {

@@ -105,4 +80,7 @@ particle.rotate.velocity *= (0, engine_1.getRandom)();

}
updateRotate(particle, delta);
particle.rotation = particle.rotate?.value ?? 0;
if (!particle.rotate) {
return;
}
(0, engine_1.updateAnimation)(particle, particle.rotate, false, "none", delta);
particle.rotation = particle.rotate.value;
}

@@ -109,0 +87,0 @@ }

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