@tsparticles/move-parallax 3.0.0-alpha.1 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadParallaxMover": () => (/* binding */ loadParallaxMover)
94
+ loadParallaxMover: () => (/* binding */ loadParallaxMover)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -105,33 +105,38 @@ class ParallaxMover {
105
105
  }
106
106
  move(particle) {
107
107
  const container = particle.container,
108
- options = container.actualOptions;
109
- if ((0,engine_root_window_.isSsr)() || !options.interactivity.events.onHover.parallax.enable) {
108
+ options = container.actualOptions,
109
+ parallaxOptions = options.interactivity.events.onHover.parallax;
110
+ if ((0,engine_root_window_.isSsr)() || !parallaxOptions.enable) {
110
111
  return;
111
112
  }
112
- const parallaxForce = options.interactivity.events.onHover.parallax.force,
113
+ const parallaxForce = parallaxOptions.force,
113
114
  mousePos = container.interactivity.mouse.position;
114
115
  if (!mousePos) {
115
116
  return;
116
117
  }
117
- const canvasCenter = {
118
- x: container.canvas.size.width / 2,
119
- y: container.canvas.size.height / 2
118
+ const canvasSize = container.canvas.size,
119
+ canvasCenter = {
120
+ x: canvasSize.width / 2,
121
+ y: canvasSize.height / 2
120
122
  },
121
- parallaxSmooth = options.interactivity.events.onHover.parallax.smooth,
123
+ parallaxSmooth = parallaxOptions.smooth,
122
124
  factor = particle.getRadius() / parallaxForce,
123
125
  centerDistance = {
124
126
  x: (mousePos.x - canvasCenter.x) * factor,
125
127
  y: (mousePos.y - canvasCenter.y) * factor
126
- };
127
- particle.offset.x += (centerDistance.x - particle.offset.x) / parallaxSmooth;
128
- particle.offset.y += (centerDistance.y - particle.offset.y) / parallaxSmooth;
128
+ },
129
+ {
130
+ offset
131
+ } = particle;
132
+ offset.x += (centerDistance.x - offset.x) / parallaxSmooth;
133
+ offset.y += (centerDistance.y - offset.y) / parallaxSmooth;
129
134
  }
130
135
  }
131
136
  ;// CONCATENATED MODULE: ./dist/browser/index.js
132
137
 
133
- async function loadParallaxMover(engine) {
134
- engine.addMover("parallax", () => new ParallaxMover());
138
+ async function loadParallaxMover(engine, refresh = true) {
139
+ await engine.addMover("parallax", () => new ParallaxMover(), refresh);
135
140
  }
136
141
  })();
137
142
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.move.parallax.min.js.LICENSE.txt */
2
- !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 r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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,{loadParallaxMover:()=>r});var e=o(533);class t{init(){}isEnabled(t){return!(0,e.isSsr)()&&!t.destroyed&&t.container.actualOptions.interactivity.events.onHover.parallax.enable}move(t){const r=t.container,o=r.actualOptions;if((0,e.isSsr)()||!o.interactivity.events.onHover.parallax.enable)return;const n=o.interactivity.events.onHover.parallax.force,i=r.interactivity.mouse.position;if(!i)return;const a=r.canvas.size.width/2,s=r.canvas.size.height/2,l=o.interactivity.events.onHover.parallax.smooth,c=t.getRadius()/n,f=(i.x-a)*c,p=(i.y-s)*c;t.offset.x+=(f-t.offset.x)/l,t.offset.y+=(p-t.offset.y)/l}}async function r(e){e.addMover("parallax",(()=>new t))}})(),n})()));
2
+ !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 r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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,{loadParallaxMover:()=>r});var e=o(533);class t{init(){}isEnabled(t){return!(0,e.isSsr)()&&!t.destroyed&&t.container.actualOptions.interactivity.events.onHover.parallax.enable}move(t){const r=t.container,o=r.actualOptions.interactivity.events.onHover.parallax;if((0,e.isSsr)()||!o.enable)return;const n=o.force,i=r.interactivity.mouse.position;if(!i)return;const a=r.canvas.size,s=a.width/2,l=a.height/2,c=o.smooth,p=t.getRadius()/n,f=(i.x-s)*p,d=(i.y-l)*p,{offset:u}=t;u.x+=(f-u.x)/c,u.y+=(d-u.y)/c}}async function r(e,r=!0){await e.addMover("parallax",(()=>new t),r)}})(),n})()));
@@ -1,8 +1 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
8
- */
1
+ /*! tsParticles Parallax Move v3.0.0-beta.1 by Matteo Bruni */
@@ -1,4 +1,4 @@
1
- import type { IParticleMover, Particle } from "@tsparticles/engine";
1
+ import { type IParticleMover, type Particle } from "@tsparticles/engine";
2
2
  export declare class ParallaxMover implements IParticleMover {
3
3
  init(): void;
4
4
  isEnabled(particle: Particle): boolean;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadParallaxMover(engine: Engine): Promise<void>;
2
+ export declare function loadParallaxMover(engine: Engine, refresh?: boolean): Promise<void>;
@@ -20,23 +20,23 @@
20
20
  particle.container.actualOptions.interactivity.events.onHover.parallax.enable);
21
21
  }
22
22
  move(particle) {
23
- const container = particle.container, options = container.actualOptions;
24
- if ((0, engine_1.isSsr)() || !options.interactivity.events.onHover.parallax.enable) {
23
+ const container = particle.container, options = container.actualOptions, parallaxOptions = options.interactivity.events.onHover.parallax;
24
+ if ((0, engine_1.isSsr)() || !parallaxOptions.enable) {
25
25
  return;
26
26
  }
27
- const parallaxForce = options.interactivity.events.onHover.parallax.force, mousePos = container.interactivity.mouse.position;
27
+ const parallaxForce = parallaxOptions.force, mousePos = container.interactivity.mouse.position;
28
28
  if (!mousePos) {
29
29
  return;
30
30
  }
31
- const canvasCenter = {
32
- x: container.canvas.size.width / 2,
33
- y: container.canvas.size.height / 2,
34
- }, parallaxSmooth = options.interactivity.events.onHover.parallax.smooth, factor = particle.getRadius() / parallaxForce, centerDistance = {
31
+ const canvasSize = container.canvas.size, canvasCenter = {
32
+ x: canvasSize.width / 2,
33
+ y: canvasSize.height / 2,
34
+ }, parallaxSmooth = parallaxOptions.smooth, factor = particle.getRadius() / parallaxForce, centerDistance = {
35
35
  x: (mousePos.x - canvasCenter.x) * factor,
36
36
  y: (mousePos.y - canvasCenter.y) * factor,
37
- };
38
- particle.offset.x += (centerDistance.x - particle.offset.x) / parallaxSmooth;
39
- particle.offset.y += (centerDistance.y - particle.offset.y) / parallaxSmooth;
37
+ }, { offset } = particle;
38
+ offset.x += (centerDistance.x - offset.x) / parallaxSmooth;
39
+ offset.y += (centerDistance.y - offset.y) / parallaxSmooth;
40
40
  }
41
41
  }
42
42
  exports.ParallaxMover = ParallaxMover;
package/umd/index.js CHANGED
@@ -4,15 +4,15 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./ParallaxMover"], factory);
7
+ define(["require", "exports", "./ParallaxMover.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadParallaxMover = void 0;
13
- const ParallaxMover_1 = require("./ParallaxMover");
14
- async function loadParallaxMover(engine) {
15
- engine.addMover("parallax", () => new ParallaxMover_1.ParallaxMover());
13
+ const ParallaxMover_js_1 = require("./ParallaxMover.js");
14
+ async function loadParallaxMover(engine, refresh = true) {
15
+ await engine.addMover("parallax", () => new ParallaxMover_js_1.ParallaxMover(), refresh);
16
16
  }
17
17
  exports.loadParallaxMover = loadParallaxMover;
18
18
  });