@supermousejs/stick 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 +10 -11
- package/dist/index.d.ts +1 -2
- package/dist/index.mjs +3 -4
- package/dist/index.umd.js +1 -1
- package/package.json +9 -4
- package/CHANGELOG.md +0 -90
- package/meta.json +0 -18
- package/src/index.ts +0 -75
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -23
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# @supermousejs/stick
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Used in combination with `@supermousejs/ring` (or SmartRing) to create a morphing effect.
|
|
3
|
+
Morphs the cursor shape to match the bounding box of hovered elements.
|
|
5
4
|
|
|
6
5
|
## Installation
|
|
7
6
|
|
|
@@ -9,24 +8,24 @@ Used in combination with `@supermousejs/ring` (or SmartRing) to create a morphin
|
|
|
9
8
|
pnpm add @supermousejs/stick
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
##
|
|
11
|
+
## Stick
|
|
12
|
+
|
|
13
|
+
Morphs the cursor shape to match the bounding box of hovered elements.
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
13
16
|
|
|
14
17
|
```ts
|
|
15
18
|
import { Supermouse } from "@supermousejs/core";
|
|
16
19
|
import { Stick } from "@supermousejs/stick";
|
|
17
|
-
import { Ring } from "@supermousejs/ring";
|
|
18
|
-
|
|
19
20
|
const app = new Supermouse();
|
|
20
|
-
|
|
21
21
|
app.use(Stick({ padding: 10 }));
|
|
22
|
-
app.use(Ring()); // Ring automatically detects 'stick' state and morphs
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
### Options
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
| Name | Type | Default | Description |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| padding | number | 10 | Extra padding around the target element in pixels. |
|
|
30
29
|
|
|
31
30
|
## Documentation
|
|
32
31
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SupermousePlugin } from '../packages/core/src';
|
|
2
|
-
import { ValueOrGetter } from '../packages/core/src';
|
|
3
2
|
|
|
4
3
|
export declare const Stick: (options?: StickOptions) => SupermousePlugin;
|
|
5
4
|
|
|
@@ -7,7 +6,7 @@ export declare interface StickOptions {
|
|
|
7
6
|
name?: string;
|
|
8
7
|
isEnabled?: boolean;
|
|
9
8
|
/** Extra padding around the element when calculating shape. Default 10. */
|
|
10
|
-
padding?:
|
|
9
|
+
padding?: number;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export { }
|
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,7 @@ const m = (a = {}) => {
|
|
|
4
4
|
let s = null, e = null;
|
|
5
5
|
return h(
|
|
6
6
|
{
|
|
7
|
-
name: a.name
|
|
8
|
-
// Logic plugin: must run before visuals to set the shape state
|
|
7
|
+
name: a.name ?? "stick",
|
|
9
8
|
priority: -10,
|
|
10
9
|
install(t) {
|
|
11
10
|
t.registerHoverTarget("[data-supermouse-stick]");
|
|
@@ -24,11 +23,11 @@ const m = (a = {}) => {
|
|
|
24
23
|
y: i.top + i.height / 2
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
t.state.target.x = e.x, t.state.target.y = e.y, t.state.shape = {
|
|
28
27
|
width: e.width,
|
|
29
28
|
height: e.height,
|
|
30
29
|
borderRadius: e.radius
|
|
31
|
-
}
|
|
30
|
+
};
|
|
32
31
|
} else
|
|
33
32
|
s && (s = null, e = null), t.state.shape = null;
|
|
34
33
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.SupermouseStick={},i.SupermouseUtils))})(this,(function(i,s){"use strict";const a=(u={})=>{const c=s.normalize(u.padding,10);let o=null,t=null;return s.definePlugin({name:u.name
|
|
1
|
+
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.SupermouseStick={},i.SupermouseUtils))})(this,(function(i,s){"use strict";const a=(u={})=>{const c=s.normalize(u.padding,10);let o=null,t=null;return s.definePlugin({name:u.name??"stick",priority:-10,install(e){e.registerHoverTarget("[data-supermouse-stick]")},update(e){const r=e.state.hoverTarget,l=e.state.interaction.stick===!0||e.state.interaction.stick==="true";if(r&&l){if(r!==o||!t){o=r;const n=s.dom.projectRect(r,e.container),h=window.getComputedStyle(r),d=c(e.state);t={width:n.width+d,height:n.height+d,radius:parseFloat(h.borderRadius)||0,x:n.left+n.width/2,y:n.top+n.height/2}}e.state.target.x=t.x,e.state.target.y=t.y,e.state.shape={width:t.width,height:t.height,borderRadius:t.radius}}else o&&(o=null,t=null),e.state.shape=null}},u)};i.Stick=a,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/stick",
|
|
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": "Morphs the cursor shape to match the bounding box of hovered elements.",
|
|
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,90 +0,0 @@
|
|
|
1
|
-
# @supermousejs/stick
|
|
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.0
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- 6d70c18: remove legacy package and update supermouse domain in readme
|
|
16
|
-
- 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
|
|
17
|
-
- Updated dependencies [6d70c18]
|
|
18
|
-
- Updated dependencies [2590af3]
|
|
19
|
-
- Updated dependencies [14fb5b6]
|
|
20
|
-
- Updated dependencies [9fe1a7b]
|
|
21
|
-
- Updated dependencies [9fa6ece]
|
|
22
|
-
- @supermousejs/core@2.1.0
|
|
23
|
-
- @supermousejs/utils@2.2.0
|
|
24
|
-
|
|
25
|
-
## 2.1.1
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- 67f771b: Add relevant npm metadata to package.json file
|
|
30
|
-
- Updated dependencies [67f771b]
|
|
31
|
-
- @supermousejs/utils@2.1.1
|
|
32
|
-
- @supermousejs/core@2.0.5
|
|
33
|
-
|
|
34
|
-
## 2.1.0
|
|
35
|
-
|
|
36
|
-
### Minor Changes
|
|
37
|
-
|
|
38
|
-
- 0a1652d: fixed build architecture and updated plugin metadata
|
|
39
|
-
|
|
40
|
-
### Patch Changes
|
|
41
|
-
|
|
42
|
-
- Updated dependencies [0a1652d]
|
|
43
|
-
- @supermousejs/utils@2.1.0
|
|
44
|
-
|
|
45
|
-
## 2.0.4
|
|
46
|
-
|
|
47
|
-
### Patch Changes
|
|
48
|
-
|
|
49
|
-
- 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
|
|
50
|
-
- Updated dependencies [993dc67]
|
|
51
|
-
- @supermousejs/utils@2.0.4
|
|
52
|
-
- @supermousejs/core@2.0.4
|
|
53
|
-
|
|
54
|
-
## 2.0.3
|
|
55
|
-
|
|
56
|
-
### Patch Changes
|
|
57
|
-
|
|
58
|
-
- Updated dependencies
|
|
59
|
-
- @supermousejs/core@2.0.3
|
|
60
|
-
- @supermousejs/utils@2.0.3
|
|
61
|
-
|
|
62
|
-
## 2.0.2
|
|
63
|
-
|
|
64
|
-
### Patch Changes
|
|
65
|
-
|
|
66
|
-
- ae219a0: Update READMEs with correct link to documentation
|
|
67
|
-
- Updated dependencies [ae219a0]
|
|
68
|
-
- @supermousejs/utils@2.0.2
|
|
69
|
-
- @supermousejs/core@2.0.2
|
|
70
|
-
|
|
71
|
-
## 2.0.1
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- Add minimal README.md files to packages
|
|
76
|
-
- Updated dependencies
|
|
77
|
-
- @supermousejs/utils@2.0.1
|
|
78
|
-
- @supermousejs/core@2.0.1
|
|
79
|
-
|
|
80
|
-
## 2.0.0
|
|
81
|
-
|
|
82
|
-
### Major Changes
|
|
83
|
-
|
|
84
|
-
- Initial v2.0.0 release
|
|
85
|
-
|
|
86
|
-
### Patch Changes
|
|
87
|
-
|
|
88
|
-
- Updated dependencies
|
|
89
|
-
- @supermousejs/utils@2.0.0
|
|
90
|
-
- @supermousejs/core@2.0.0
|
package/meta.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "stick",
|
|
3
|
-
"name": "Stick",
|
|
4
|
-
"package": "@supermousejs/stick",
|
|
5
|
-
"description": "Morphs the cursor shape to match the bounding box of hovered elements.",
|
|
6
|
-
"code": "app.use(Stick({ padding: 10 }));",
|
|
7
|
-
"recipeId": "sticky-element",
|
|
8
|
-
"icon": "stick",
|
|
9
|
-
"options": [
|
|
10
|
-
{
|
|
11
|
-
"name": "padding",
|
|
12
|
-
"type": "number",
|
|
13
|
-
"default": "10",
|
|
14
|
-
"description": "Extra padding around the target element in pixels.",
|
|
15
|
-
"reactive": true
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { ValueOrGetter, Supermouse } from "@supermousejs/core";
|
|
2
|
-
import { definePlugin, normalize, dom } from "@supermousejs/utils";
|
|
3
|
-
|
|
4
|
-
export interface StickOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
isEnabled?: boolean;
|
|
7
|
-
/** Extra padding around the element when calculating shape. Default 10. */
|
|
8
|
-
padding?: ValueOrGetter<number>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Stick = (options: StickOptions = {}) => {
|
|
12
|
-
const getPadding = normalize(options.padding, 10);
|
|
13
|
-
|
|
14
|
-
let lastTarget: HTMLElement | null = null;
|
|
15
|
-
let cache: { width: number; height: number; radius: number; x: number; y: number } | null = null;
|
|
16
|
-
|
|
17
|
-
return definePlugin(
|
|
18
|
-
{
|
|
19
|
-
name: options.name || "stick",
|
|
20
|
-
// Logic plugin: must run before visuals to set the shape state
|
|
21
|
-
priority: -10,
|
|
22
|
-
|
|
23
|
-
install(app: Supermouse) {
|
|
24
|
-
app.registerHoverTarget("[data-supermouse-stick]");
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
update(app: Supermouse) {
|
|
28
|
-
// Check normalized interaction key (camelCase, no prefix)
|
|
29
|
-
const target = app.state.hoverTarget;
|
|
30
|
-
const isSticky =
|
|
31
|
-
app.state.interaction.stick === true || app.state.interaction.stick === "true";
|
|
32
|
-
|
|
33
|
-
if (target && isSticky) {
|
|
34
|
-
// Recalculate only if target changed or on first frame
|
|
35
|
-
if (target !== lastTarget || !cache) {
|
|
36
|
-
lastTarget = target;
|
|
37
|
-
|
|
38
|
-
const rect = dom.projectRect(target, app.container);
|
|
39
|
-
const style = window.getComputedStyle(target);
|
|
40
|
-
const padding = getPadding(app.state);
|
|
41
|
-
|
|
42
|
-
cache = {
|
|
43
|
-
width: rect.width + padding,
|
|
44
|
-
height: rect.height + padding,
|
|
45
|
-
radius: parseFloat(style.borderRadius) || 0,
|
|
46
|
-
x: rect.left + rect.width / 2,
|
|
47
|
-
y: rect.top + rect.height / 2
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (cache) {
|
|
52
|
-
// 1. Override Target (Physics) - Snap target to center of element
|
|
53
|
-
app.state.target.x = cache.x;
|
|
54
|
-
app.state.target.y = cache.y;
|
|
55
|
-
|
|
56
|
-
// 2. Set Shape (Visuals) - Visual plugins like Ring will read this
|
|
57
|
-
app.state.shape = {
|
|
58
|
-
width: cache.width,
|
|
59
|
-
height: cache.height,
|
|
60
|
-
borderRadius: cache.radius
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
// Reset
|
|
65
|
-
if (lastTarget) {
|
|
66
|
-
lastTarget = null;
|
|
67
|
-
cache = null;
|
|
68
|
-
}
|
|
69
|
-
app.state.shape = null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
options
|
|
74
|
-
);
|
|
75
|
-
};
|
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: "SupermouseStick",
|
|
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
|
-
});
|