@supermousejs/stick 2.1.1 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,68 +1,82 @@
1
- # @supermousejs/stick
2
-
3
- ## 2.1.1
4
-
5
- ### Patch Changes
6
-
7
- - 67f771b: Add relevant npm metadata to package.json file
8
- - Updated dependencies [67f771b]
9
- - @supermousejs/utils@2.1.1
10
- - @supermousejs/core@2.0.5
11
-
12
- ## 2.1.0
13
-
14
- ### Minor Changes
15
-
16
- - 0a1652d: fixed build architecture and updated plugin metadata
17
-
18
- ### Patch Changes
19
-
20
- - Updated dependencies [0a1652d]
21
- - @supermousejs/utils@2.1.0
22
-
23
- ## 2.0.4
24
-
25
- ### Patch Changes
26
-
27
- - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
28
- - Updated dependencies [993dc67]
29
- - @supermousejs/utils@2.0.4
30
- - @supermousejs/core@2.0.4
31
-
32
- ## 2.0.3
33
-
34
- ### Patch Changes
35
-
36
- - Updated dependencies
37
- - @supermousejs/core@2.0.3
38
- - @supermousejs/utils@2.0.3
39
-
40
- ## 2.0.2
41
-
42
- ### Patch Changes
43
-
44
- - ae219a0: Update READMEs with correct link to documentation
45
- - Updated dependencies [ae219a0]
46
- - @supermousejs/utils@2.0.2
47
- - @supermousejs/core@2.0.2
48
-
49
- ## 2.0.1
50
-
51
- ### Patch Changes
52
-
53
- - Add minimal README.md files to packages
54
- - Updated dependencies
55
- - @supermousejs/utils@2.0.1
56
- - @supermousejs/core@2.0.1
57
-
58
- ## 2.0.0
59
-
60
- ### Major Changes
61
-
62
- - Initial v2.0.0 release
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies
67
- - @supermousejs/utils@2.0.0
68
- - @supermousejs/core@2.0.0
1
+ # @supermousejs/stick
2
+
3
+ ## 2.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d70c18: remove legacy package and update supermouse domain in readme
8
+ - 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
9
+ - Updated dependencies [6d70c18]
10
+ - Updated dependencies [2590af3]
11
+ - Updated dependencies [14fb5b6]
12
+ - Updated dependencies [9fe1a7b]
13
+ - Updated dependencies [9fa6ece]
14
+ - @supermousejs/core@2.1.0
15
+ - @supermousejs/utils@2.2.0
16
+
17
+ ## 2.1.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 67f771b: Add relevant npm metadata to package.json file
22
+ - Updated dependencies [67f771b]
23
+ - @supermousejs/utils@2.1.1
24
+ - @supermousejs/core@2.0.5
25
+
26
+ ## 2.1.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 0a1652d: fixed build architecture and updated plugin metadata
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [0a1652d]
35
+ - @supermousejs/utils@2.1.0
36
+
37
+ ## 2.0.4
38
+
39
+ ### Patch Changes
40
+
41
+ - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
42
+ - Updated dependencies [993dc67]
43
+ - @supermousejs/utils@2.0.4
44
+ - @supermousejs/core@2.0.4
45
+
46
+ ## 2.0.3
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies
51
+ - @supermousejs/core@2.0.3
52
+ - @supermousejs/utils@2.0.3
53
+
54
+ ## 2.0.2
55
+
56
+ ### Patch Changes
57
+
58
+ - ae219a0: Update READMEs with correct link to documentation
59
+ - Updated dependencies [ae219a0]
60
+ - @supermousejs/utils@2.0.2
61
+ - @supermousejs/core@2.0.2
62
+
63
+ ## 2.0.1
64
+
65
+ ### Patch Changes
66
+
67
+ - Add minimal README.md files to packages
68
+ - Updated dependencies
69
+ - @supermousejs/utils@2.0.1
70
+ - @supermousejs/core@2.0.1
71
+
72
+ ## 2.0.0
73
+
74
+ ### Major Changes
75
+
76
+ - Initial v2.0.0 release
77
+
78
+ ### Patch Changes
79
+
80
+ - Updated dependencies
81
+ - @supermousejs/utils@2.0.0
82
+ - @supermousejs/core@2.0.0
package/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Sijibomi Olusunmbola
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sijibomi Olusunmbola
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
-
2
- # @supermousejs/stick
3
-
4
- A **Logic Plugin** that calculates the bounding box of hovered elements.
5
- Used in combination with `@supermousejs/ring` (or SmartRing) to create a morphing effect.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- pnpm add @supermousejs/stick
11
- ```
12
-
13
- ## Usage
14
-
15
- ```ts
16
- import { Supermouse } from '@supermousejs/core';
17
- import { Stick } from '@supermousejs/stick';
18
- import { Ring } from '@supermousejs/ring';
19
-
20
- const app = new Supermouse();
21
-
22
- app.use(Stick({ padding: 10 }));
23
- app.use(Ring()); // Ring automatically detects 'stick' state and morphs
24
- ```
25
-
26
- **HTML:**
27
- ```html
28
- <button data-supermouse-stick="true">Sticky Element</button>
29
- ```
30
-
31
- ## Documentation
32
-
33
- Full documentation and interactive playground available at [supermouse](https://supermouse.vercel.app) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
1
+ # @supermousejs/stick
2
+
3
+ A **Logic Plugin** that calculates the bounding box of hovered elements.
4
+ Used in combination with `@supermousejs/ring` (or SmartRing) to create a morphing effect.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ pnpm add @supermousejs/stick
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import { Supermouse } from "@supermousejs/core";
16
+ import { Stick } from "@supermousejs/stick";
17
+ import { Ring } from "@supermousejs/ring";
18
+
19
+ const app = new Supermouse();
20
+
21
+ app.use(Stick({ padding: 10 }));
22
+ app.use(Ring()); // Ring automatically detects 'stick' state and morphs
23
+ ```
24
+
25
+ **HTML:**
26
+
27
+ ```html
28
+ <button data-supermouse-stick="true">Sticky Element</button>
29
+ ```
30
+
31
+ ## Documentation
32
+
33
+ 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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SupermousePlugin } from '../../core/src/index.ts';
2
- import { ValueOrGetter } from '../../core/src/index.ts';
1
+ import { SupermousePlugin } from '../../core/src';
2
+ import { ValueOrGetter } from '../../core/src';
3
3
 
4
4
  export declare const Stick: (options?: StickOptions) => SupermousePlugin;
5
5
 
package/dist/index.mjs CHANGED
@@ -2,36 +2,39 @@ import { normalize as c, definePlugin as h, dom as g } from "@supermousejs/utils
2
2
  const m = (a = {}) => {
3
3
  const d = c(a.padding, 10);
4
4
  let s = null, e = null;
5
- return h({
6
- name: a.name || "stick",
7
- // Logic plugin: must run before visuals to set the shape state
8
- priority: -10,
9
- install(t) {
10
- t.registerHoverTarget("[data-supermouse-stick]");
5
+ return h(
6
+ {
7
+ name: a.name || "stick",
8
+ // Logic plugin: must run before visuals to set the shape state
9
+ priority: -10,
10
+ install(t) {
11
+ t.registerHoverTarget("[data-supermouse-stick]");
12
+ },
13
+ update(t) {
14
+ const r = t.state.hoverTarget, l = t.state.interaction.stick === !0 || t.state.interaction.stick === "true";
15
+ if (r && l) {
16
+ if (r !== s || !e) {
17
+ s = r;
18
+ const i = g.projectRect(r, t.container), o = window.getComputedStyle(r), n = d(t.state);
19
+ e = {
20
+ width: i.width + n,
21
+ height: i.height + n,
22
+ radius: parseFloat(o.borderRadius) || 0,
23
+ x: i.left + i.width / 2,
24
+ y: i.top + i.height / 2
25
+ };
26
+ }
27
+ e && (t.state.target.x = e.x, t.state.target.y = e.y, t.state.shape = {
28
+ width: e.width,
29
+ height: e.height,
30
+ borderRadius: e.radius
31
+ });
32
+ } else
33
+ s && (s = null, e = null), t.state.shape = null;
34
+ }
11
35
  },
12
- update(t) {
13
- const r = t.state.hoverTarget, l = t.state.interaction.stick === !0 || t.state.interaction.stick === "true";
14
- if (r && l) {
15
- if (r !== s || !e) {
16
- s = r;
17
- const i = g.projectRect(r, t.container), o = window.getComputedStyle(r), n = d(t.state);
18
- e = {
19
- width: i.width + n,
20
- height: i.height + n,
21
- radius: parseFloat(o.borderRadius) || 0,
22
- x: i.left + i.width / 2,
23
- y: i.top + i.height / 2
24
- };
25
- }
26
- e && (t.state.target.x = e.x, t.state.target.y = e.y, t.state.shape = {
27
- width: e.width,
28
- height: e.height,
29
- borderRadius: e.radius
30
- });
31
- } else
32
- s && (s = null, e = null), t.state.shape = null;
33
- }
34
- }, a);
36
+ a
37
+ );
35
38
  };
36
39
  export {
37
40
  m as Stick
package/meta.json CHANGED
@@ -1,13 +1,18 @@
1
-
2
- {
3
- "id": "stick",
4
- "name": "Stick",
5
- "package": "@supermousejs/stick",
6
- "description": "Morphs the cursor shape to match the bounding box of hovered elements.",
7
- "code": "app.use(Stick({ padding: 10 }));",
8
- "recipeId": "sticky-element",
9
- "icon": "stick",
10
- "options": [
11
- { "name": "padding", "type": "number", "default": "10", "description": "Extra padding around the target element in pixels.", "reactive": true }
12
- ]
13
- }
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supermousejs/stick",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "main": "dist/index.umd.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -8,13 +8,13 @@
8
8
  "url": "https://github.com/Whitestar14/supermouse-js",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "@supermousejs/utils": "2.1.1"
11
+ "@supermousejs/utils": "2.2.0"
12
12
  },
13
13
  "devDependencies": {
14
- "@supermousejs/core": "2.0.5"
14
+ "@supermousejs/core": "2.1.0"
15
15
  },
16
16
  "peerDependencies": {
17
- "@supermousejs/core": "2.0.5"
17
+ "@supermousejs/core": "2.1.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
package/src/index.ts CHANGED
@@ -1,73 +1,75 @@
1
-
2
- import type { ValueOrGetter } from '@supermousejs/core';
3
- import { definePlugin, normalize, dom } from '@supermousejs/utils';
4
-
5
- export interface StickOptions {
6
- name?: string;
7
- isEnabled?: boolean;
8
- /** Extra padding around the element when calculating shape. Default 10. */
9
- padding?: ValueOrGetter<number>;
10
- }
11
-
12
- export const Stick = (options: StickOptions = {}) => {
13
- const getPadding = normalize(options.padding, 10);
14
-
15
- let lastTarget: HTMLElement | null = null;
16
- let cache: { width: number; height: number; radius: number; x: number; y: number } | null = null;
17
-
18
- return definePlugin({
19
- name: options.name || 'stick',
20
- // Logic plugin: must run before visuals to set the shape state
21
- priority: -10,
22
-
23
- install(app) {
24
- app.registerHoverTarget('[data-supermouse-stick]');
25
- },
26
-
27
- update(app) {
28
- // Check normalized interaction key (camelCase, no prefix)
29
- const target = app.state.hoverTarget;
30
- const isSticky = app.state.interaction.stick === true || app.state.interaction.stick === 'true';
31
-
32
- if (target && isSticky) {
33
-
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
- }, options);
73
- };
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 CHANGED
@@ -1,18 +1,4 @@
1
1
  {
2
- "extends": "../../tsconfig.base.json",
3
- "include": [
4
- "src"
5
- ],
6
- "compilerOptions": {
7
- "outDir": "dist",
8
- "baseUrl": ".",
9
- "paths": {
10
- "@supermousejs/core": [
11
- "../core/src/index.ts"
12
- ],
13
- "@supermousejs/utils": [
14
- "../utils/src/index.ts"
15
- ]
16
- }
17
- }
18
- }
2
+ "extends": "../../tsconfig.plugin.json",
3
+ "include": ["src"]
4
+ }
package/vite.config.ts CHANGED
@@ -1,22 +1,23 @@
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
- plugins: [dts({ rollupTypes: true })]
22
- });
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
+ });