@supermousejs/trail 2.3.0 → 2.4.0
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/dist/index.mjs +21 -17
- package/dist/index.umd.js +1 -1
- package/package.json +9 -4
- package/CHANGELOG.md +0 -96
- package/meta.json +0 -32
- package/src/index.ts +0 -66
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -23
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @supermousejs/trail
|
|
2
2
|
|
|
3
|
-
Generates
|
|
3
|
+
Generates procedural particles that trail behind your motion
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,23 +8,27 @@ Generates a procedural particle trail that follows the cursor.
|
|
|
8
8
|
pnpm add @supermousejs/trail
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Trail
|
|
12
|
+
|
|
13
|
+
Generates procedural particles that trail behind your motion.
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
12
16
|
|
|
13
17
|
```ts
|
|
14
18
|
import { Supermouse } from "@supermousejs/core";
|
|
15
19
|
import { Trail } from "@supermousejs/trail";
|
|
16
|
-
|
|
17
20
|
const app = new Supermouse();
|
|
18
|
-
|
|
19
|
-
app.use(
|
|
20
|
-
Trail({
|
|
21
|
-
length: 10, // Number of segments
|
|
22
|
-
size: 6, // Particle size
|
|
23
|
-
color: "#ff00ff"
|
|
24
|
-
})
|
|
25
|
-
);
|
|
21
|
+
app.use(Trail({ length: 12, color: '#f0f' }));
|
|
26
22
|
```
|
|
27
23
|
|
|
24
|
+
### Options
|
|
25
|
+
|
|
26
|
+
| Name | Type | Default | Description |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| length | number | 10 | Number of trail segments. |
|
|
29
|
+
| size | number | 6 | Size of trail particles. |
|
|
30
|
+
| color | string | '#ff00ff' | Color of segments. |
|
|
31
|
+
|
|
28
32
|
## Documentation
|
|
29
33
|
|
|
30
34
|
Full documentation and interactive playground available at [supermouse](https://supermouse.js.org) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
|
package/dist/index.mjs
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import { normalize as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
import { normalize as f, definePlugin as p, dom as r, Layers as z } from "@supermousejs/utils";
|
|
2
|
+
const b = (o = {}) => {
|
|
3
|
+
const c = o.length || 10, g = f(o.size, 6), m = f(o.color, "#ff00ff"), a = [], s = [];
|
|
4
4
|
return p(
|
|
5
5
|
{
|
|
6
|
-
name:
|
|
6
|
+
name: o.name || "trail",
|
|
7
7
|
create: () => {
|
|
8
|
-
a.length = 0,
|
|
9
|
-
const t =
|
|
8
|
+
a.length = 0, s.length = 0;
|
|
9
|
+
const t = r.createActor("div");
|
|
10
10
|
t.style.zIndex = z.TRACE;
|
|
11
|
-
for (let
|
|
12
|
-
const e =
|
|
13
|
-
e.style.position = "absolute", e.style.opacity = String(1 -
|
|
11
|
+
for (let n = 0; n < c; n++) {
|
|
12
|
+
const e = r.createCircle(0, "#000");
|
|
13
|
+
e.style.position = "absolute", e.style.opacity = String(1 - n / c), t.appendChild(e), a.push(e), s.push({ x: -100, y: -100 });
|
|
14
14
|
}
|
|
15
15
|
return t;
|
|
16
16
|
},
|
|
17
17
|
update: (t) => {
|
|
18
|
-
const { x:
|
|
19
|
-
|
|
20
|
-
const u =
|
|
21
|
-
a.forEach((
|
|
22
|
-
const h =
|
|
23
|
-
|
|
18
|
+
const { x: n, y: e } = t.state.smooth;
|
|
19
|
+
s.pop(), s.unshift({ x: n, y: e });
|
|
20
|
+
const u = g(t.state), y = m(t.state);
|
|
21
|
+
a.forEach((l, i) => {
|
|
22
|
+
const h = s[i], x = 1 - i / c, d = u * x;
|
|
23
|
+
r.css(l, {
|
|
24
|
+
width: `${d}px`,
|
|
25
|
+
height: `${d}px`,
|
|
26
|
+
backgroundColor: y
|
|
27
|
+
}), r.setTransform(l, h.x, h.y);
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
|
-
|
|
31
|
+
o
|
|
28
32
|
);
|
|
29
33
|
};
|
|
30
34
|
export {
|
|
31
|
-
|
|
35
|
+
b as Trail
|
|
32
36
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SupermouseTrail={},t.SupermouseUtils))})(this,(function(t,e){"use strict";const
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.SupermouseTrail={},t.SupermouseUtils))})(this,(function(t,e){"use strict";const m=(s={})=>{const i=s.length||10,h=e.normalize(s.size,6),p=e.normalize(s.color,"#ff00ff"),d=[],r=[];return e.definePlugin({name:s.name||"trail",create:()=>{d.length=0,r.length=0;const o=e.dom.createActor("div");o.style.zIndex=e.Layers.TRACE;for(let c=0;c<i;c++){const n=e.dom.createCircle(0,"#000");n.style.position="absolute",n.style.opacity=String(1-c/i),o.appendChild(n),d.push(n),r.push({x:-100,y:-100})}return o},update:o=>{const{x:c,y:n}=o.state.smooth;r.pop(),r.unshift({x:c,y:n});const y=h(o.state),g=p(o.state);d.forEach((a,l)=>{const u=r[l],x=1-l/i,f=y*x;e.dom.css(a,{width:`${f}px`,height:`${f}px`,backgroundColor:g}),e.dom.setTransform(a,u.x,u.y)})}},s)};t.Trail=m,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/trail",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"main": "dist/index.umd.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"description": "Generates procedural particles that trail behind your motion",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
7
12
|
"author": "O.S David",
|
|
8
13
|
"url": "https://github.com/Whitestar14/supermouse-js",
|
|
9
14
|
"license": "MIT",
|
|
10
15
|
"dependencies": {
|
|
11
|
-
"@supermousejs/utils": "2.
|
|
16
|
+
"@supermousejs/utils": "2.4.0"
|
|
12
17
|
},
|
|
13
18
|
"devDependencies": {
|
|
14
|
-
"@supermousejs/core": "2.
|
|
19
|
+
"@supermousejs/core": "2.4.0"
|
|
15
20
|
},
|
|
16
21
|
"peerDependencies": {
|
|
17
|
-
"@supermousejs/core": "2.
|
|
22
|
+
"@supermousejs/core": "2.4.0"
|
|
18
23
|
},
|
|
19
24
|
"repository": {
|
|
20
25
|
"type": "git",
|
package/CHANGELOG.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# @supermousejs/trail
|
|
2
|
-
|
|
3
|
-
## 2.3.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [f6f44b2]
|
|
8
|
-
- @supermousejs/core@2.2.0
|
|
9
|
-
- @supermousejs/utils@2.3.0
|
|
10
|
-
|
|
11
|
-
## 2.2.1
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- a72f5a3: bugfix: fixed a type declaration issue from missing `return` keyword with the Trail package export
|
|
16
|
-
|
|
17
|
-
## 2.2.0
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- 6d70c18: remove legacy package and update supermouse domain in readme
|
|
22
|
-
- 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
|
|
23
|
-
- Updated dependencies [6d70c18]
|
|
24
|
-
- Updated dependencies [2590af3]
|
|
25
|
-
- Updated dependencies [14fb5b6]
|
|
26
|
-
- Updated dependencies [9fe1a7b]
|
|
27
|
-
- Updated dependencies [9fa6ece]
|
|
28
|
-
- @supermousejs/core@2.1.0
|
|
29
|
-
- @supermousejs/utils@2.2.0
|
|
30
|
-
|
|
31
|
-
## 2.1.1
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- 67f771b: Add relevant npm metadata to package.json file
|
|
36
|
-
- Updated dependencies [67f771b]
|
|
37
|
-
- @supermousejs/utils@2.1.1
|
|
38
|
-
- @supermousejs/core@2.0.5
|
|
39
|
-
|
|
40
|
-
## 2.1.0
|
|
41
|
-
|
|
42
|
-
### Minor Changes
|
|
43
|
-
|
|
44
|
-
- 0a1652d: fixed build architecture and updated plugin metadata
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- Updated dependencies [0a1652d]
|
|
49
|
-
- @supermousejs/utils@2.1.0
|
|
50
|
-
|
|
51
|
-
## 2.0.4
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
|
|
56
|
-
- Updated dependencies [993dc67]
|
|
57
|
-
- @supermousejs/utils@2.0.4
|
|
58
|
-
- @supermousejs/core@2.0.4
|
|
59
|
-
|
|
60
|
-
## 2.0.3
|
|
61
|
-
|
|
62
|
-
### Patch Changes
|
|
63
|
-
|
|
64
|
-
- Updated dependencies
|
|
65
|
-
- @supermousejs/core@2.0.3
|
|
66
|
-
- @supermousejs/utils@2.0.3
|
|
67
|
-
|
|
68
|
-
## 2.0.2
|
|
69
|
-
|
|
70
|
-
### Patch Changes
|
|
71
|
-
|
|
72
|
-
- ae219a0: Update READMEs with correct link to documentation
|
|
73
|
-
- Updated dependencies [ae219a0]
|
|
74
|
-
- @supermousejs/utils@2.0.2
|
|
75
|
-
- @supermousejs/core@2.0.2
|
|
76
|
-
|
|
77
|
-
## 2.0.1
|
|
78
|
-
|
|
79
|
-
### Patch Changes
|
|
80
|
-
|
|
81
|
-
- Add minimal README.md files to packages
|
|
82
|
-
- Updated dependencies
|
|
83
|
-
- @supermousejs/utils@2.0.1
|
|
84
|
-
- @supermousejs/core@2.0.1
|
|
85
|
-
|
|
86
|
-
## 2.0.0
|
|
87
|
-
|
|
88
|
-
### Major Changes
|
|
89
|
-
|
|
90
|
-
- Initial v2.0.0 release
|
|
91
|
-
|
|
92
|
-
### Patch Changes
|
|
93
|
-
|
|
94
|
-
- Updated dependencies
|
|
95
|
-
- @supermousejs/utils@2.0.0
|
|
96
|
-
- @supermousejs/core@2.0.0
|
package/meta.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "trail",
|
|
3
|
-
"name": "Trail",
|
|
4
|
-
"package": "@supermousejs/trail",
|
|
5
|
-
"description": "Generates procedural particles that trail behind your motion.",
|
|
6
|
-
"code": "app.use(Trail({ length: 12, color: '#f0f' }));",
|
|
7
|
-
"recipeId": "ghost-trail",
|
|
8
|
-
"icon": "trail",
|
|
9
|
-
"options": [
|
|
10
|
-
{
|
|
11
|
-
"name": "length",
|
|
12
|
-
"type": "number",
|
|
13
|
-
"default": "10",
|
|
14
|
-
"description": "Number of trail segments.",
|
|
15
|
-
"reactive": false
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "size",
|
|
19
|
-
"type": "number",
|
|
20
|
-
"default": "6",
|
|
21
|
-
"description": "Size of trail particles.",
|
|
22
|
-
"reactive": true
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "color",
|
|
26
|
-
"type": "string",
|
|
27
|
-
"default": "'#ff00ff'",
|
|
28
|
-
"description": "Color of segments.",
|
|
29
|
-
"reactive": true
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { ValueOrGetter, Supermouse } from "@supermousejs/core";
|
|
2
|
-
import { definePlugin, normalize, dom, Layers } from "@supermousejs/utils";
|
|
3
|
-
|
|
4
|
-
export interface TrailOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
isEnabled?: boolean;
|
|
7
|
-
length?: number;
|
|
8
|
-
size?: ValueOrGetter<number>;
|
|
9
|
-
color?: ValueOrGetter<string>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Trail = (options: TrailOptions = {}) => {
|
|
13
|
-
const length = options.length || 10;
|
|
14
|
-
const getSize = normalize(options.size, 6);
|
|
15
|
-
const getColor = normalize(options.color, "#ff00ff");
|
|
16
|
-
|
|
17
|
-
const segments: HTMLDivElement[] = [];
|
|
18
|
-
const history: { x: number; y: number }[] = [];
|
|
19
|
-
|
|
20
|
-
return definePlugin<HTMLDivElement, TrailOptions>(
|
|
21
|
-
{
|
|
22
|
-
name: options.name || "trail",
|
|
23
|
-
|
|
24
|
-
create: () => {
|
|
25
|
-
segments.length = 0;
|
|
26
|
-
history.length = 0;
|
|
27
|
-
const container = dom.createActor("div") as HTMLDivElement;
|
|
28
|
-
container.style.zIndex = Layers.TRACE;
|
|
29
|
-
|
|
30
|
-
for (let i = 0; i < length; i++) {
|
|
31
|
-
const d = dom.createCircle(0, "#000");
|
|
32
|
-
d.style.position = "absolute";
|
|
33
|
-
d.style.opacity = String(1 - i / length);
|
|
34
|
-
container.appendChild(d);
|
|
35
|
-
segments.push(d);
|
|
36
|
-
history.push({ x: -100, y: -100 });
|
|
37
|
-
}
|
|
38
|
-
return container;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
update: (app: Supermouse) => {
|
|
42
|
-
const { x, y } = app.state.smooth;
|
|
43
|
-
|
|
44
|
-
// Shift history
|
|
45
|
-
history.pop();
|
|
46
|
-
history.unshift({ x, y });
|
|
47
|
-
|
|
48
|
-
const baseSize = getSize(app.state);
|
|
49
|
-
const color = getColor(app.state);
|
|
50
|
-
|
|
51
|
-
segments.forEach((seg, i) => {
|
|
52
|
-
const pos = history[i];
|
|
53
|
-
const scale = 1 - i / length;
|
|
54
|
-
const size = baseSize * scale;
|
|
55
|
-
|
|
56
|
-
dom.setStyle(seg, "width", `${size}px`);
|
|
57
|
-
dom.setStyle(seg, "height", `${size}px`);
|
|
58
|
-
dom.setStyle(seg, "backgroundColor", color);
|
|
59
|
-
|
|
60
|
-
dom.setTransform(seg, pos.x, pos.y);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
options
|
|
65
|
-
);
|
|
66
|
-
};
|
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import dts from "vite-plugin-dts";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
build: {
|
|
7
|
-
lib: {
|
|
8
|
-
entry: path.resolve(__dirname, "src/index.ts"),
|
|
9
|
-
name: "SupermouseTrail",
|
|
10
|
-
fileName: (format) => (format === "es" ? "index.mjs" : "index.umd.js")
|
|
11
|
-
},
|
|
12
|
-
rollupOptions: {
|
|
13
|
-
external: ["@supermousejs/core", "@supermousejs/utils"],
|
|
14
|
-
output: {
|
|
15
|
-
globals: {
|
|
16
|
-
"@supermousejs/core": "SupermouseCore",
|
|
17
|
-
"@supermousejs/utils": "SupermouseUtils"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
plugins: [dts({ rollupTypes: true })]
|
|
23
|
-
});
|