@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.
- package/README.md +15 -11
- package/browser/ParallaxMover.js +10 -10
- package/browser/index.js +3 -3
- package/browser/package.json +1 -0
- package/cjs/ParallaxMover.js +10 -10
- package/cjs/index.js +3 -14
- package/cjs/package.json +1 -0
- package/esm/ParallaxMover.js +10 -10
- package/esm/index.js +3 -3
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.move.parallax.js +19 -14
- package/tsparticles.move.parallax.min.js +1 -1
- package/tsparticles.move.parallax.min.js.LICENSE.txt +1 -8
- package/types/ParallaxMover.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/ParallaxMover.js +10 -10
- package/umd/index.js +4 -4
|
@@ -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-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
113
|
+
const parallaxForce = parallaxOptions.force,
|
|
113
114
|
mousePos = container.interactivity.mouse.position;
|
|
114
115
|
if (!mousePos) {
|
|
115
116
|
return;
|
|
116
117
|
}
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const canvasSize = container.canvas.size,
|
|
119
|
+
canvasCenter = {
|
|
120
|
+
x: canvasSize.width / 2,
|
|
121
|
+
y: canvasSize.height / 2
|
|
120
122
|
},
|
|
121
|
-
parallaxSmooth =
|
|
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
|
-
|
|
128
|
-
|
|
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.
|
|
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 */
|
package/types/ParallaxMover.d.ts
CHANGED
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>;
|
package/umd/ParallaxMover.js
CHANGED
|
@@ -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)() || !
|
|
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 =
|
|
27
|
+
const parallaxForce = parallaxOptions.force, mousePos = container.interactivity.mouse.position;
|
|
28
28
|
if (!mousePos) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
const canvasCenter = {
|
|
32
|
-
x:
|
|
33
|
-
y:
|
|
34
|
-
}, parallaxSmooth =
|
|
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
|
-
|
|
39
|
-
|
|
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
|
|
14
|
-
async function loadParallaxMover(engine) {
|
|
15
|
-
engine.addMover("parallax", () => new
|
|
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
|
});
|