@supermousejs/ring 2.1.0 → 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 +87 -59
- package/LICENSE.md +21 -21
- package/README.md +30 -29
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +33 -24
- package/dist/index.umd.js +1 -1
- package/meta.json +46 -17
- package/package.json +13 -4
- package/src/index.ts +56 -56
- package/tsconfig.json +3 -17
- package/vite.config.ts +23 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,59 +1,87 @@
|
|
|
1
|
-
# @supermousejs/ring
|
|
2
|
-
|
|
3
|
-
## 2.
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- @supermousejs/utils@2.0
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Updated dependencies
|
|
28
|
-
- @supermousejs/
|
|
29
|
-
- @supermousejs/
|
|
30
|
-
|
|
31
|
-
## 2.0
|
|
32
|
-
|
|
33
|
-
###
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
# @supermousejs/ring
|
|
2
|
+
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9fe1a7b: - Implemented idiomatic approach to using supermouse/utils
|
|
8
|
+
- Rewrote `applyStyles`, `setTransform` and `setStyles` to share a global cache registry
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 6d70c18: remove legacy package and update supermouse domain in readme
|
|
13
|
+
- 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
|
|
14
|
+
- Updated dependencies [6d70c18]
|
|
15
|
+
- Updated dependencies [2590af3]
|
|
16
|
+
- Updated dependencies [14fb5b6]
|
|
17
|
+
- Updated dependencies [9fe1a7b]
|
|
18
|
+
- Updated dependencies [9fa6ece]
|
|
19
|
+
- @supermousejs/core@2.1.0
|
|
20
|
+
- @supermousejs/utils@2.2.0
|
|
21
|
+
|
|
22
|
+
## 2.1.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 67f771b: Add relevant npm metadata to package.json file
|
|
27
|
+
- Updated dependencies [67f771b]
|
|
28
|
+
- @supermousejs/utils@2.1.1
|
|
29
|
+
- @supermousejs/core@2.0.5
|
|
30
|
+
|
|
31
|
+
## 2.1.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- 0a1652d: fixed build architecture and updated plugin metadata
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [0a1652d]
|
|
40
|
+
- @supermousejs/utils@2.1.0
|
|
41
|
+
|
|
42
|
+
## 2.0.4
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
|
|
47
|
+
- Updated dependencies [993dc67]
|
|
48
|
+
- @supermousejs/utils@2.0.4
|
|
49
|
+
- @supermousejs/core@2.0.4
|
|
50
|
+
|
|
51
|
+
## 2.0.3
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies
|
|
56
|
+
- @supermousejs/core@2.0.3
|
|
57
|
+
- @supermousejs/utils@2.0.3
|
|
58
|
+
|
|
59
|
+
## 2.0.2
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- ae219a0: Update READMEs with correct link to documentation
|
|
64
|
+
- Updated dependencies [ae219a0]
|
|
65
|
+
- @supermousejs/utils@2.0.2
|
|
66
|
+
- @supermousejs/core@2.0.2
|
|
67
|
+
|
|
68
|
+
## 2.0.1
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Add minimal README.md files to packages
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- @supermousejs/utils@2.0.1
|
|
75
|
+
- @supermousejs/core@2.0.1
|
|
76
|
+
|
|
77
|
+
## 2.0.0
|
|
78
|
+
|
|
79
|
+
### Major Changes
|
|
80
|
+
|
|
81
|
+
- Initial v2.0.0 release
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies
|
|
86
|
+
- @supermousejs/utils@2.0.0
|
|
87
|
+
- @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,29 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
# @supermousejs/ring
|
|
2
|
+
|
|
3
|
+
The standard Ring cursor plugin for **Supermouse v2**. Supports morphing when used with the Stick logic plugin.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @supermousejs/ring
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Supermouse } from "@supermousejs/core";
|
|
15
|
+
import { Ring } from "@supermousejs/ring";
|
|
16
|
+
|
|
17
|
+
const app = new Supermouse();
|
|
18
|
+
|
|
19
|
+
app.use(
|
|
20
|
+
Ring({
|
|
21
|
+
size: 20,
|
|
22
|
+
color: "black",
|
|
23
|
+
borderWidth: 2
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
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
|
|
2
|
-
import { ValueOrGetter } from '../../core/src
|
|
1
|
+
import { SupermousePlugin } from '../../core/src';
|
|
2
|
+
import { ValueOrGetter } from '../../core/src';
|
|
3
3
|
|
|
4
4
|
export declare const Ring: (options?: RingOptions) => SupermousePlugin;
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import { normalize as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { normalize as o, definePlugin as y, dom as s, Layers as g } from "@supermousejs/utils";
|
|
2
|
+
const b = (t = {}) => {
|
|
3
|
+
const n = o(t.size, 20), i = o(t.color, "#ffffff"), c = o(t.borderWidth, 2), d = o(t.opacity, 1);
|
|
4
|
+
return y(
|
|
5
|
+
{
|
|
6
|
+
name: t.name || "ring",
|
|
7
|
+
selector: "[data-supermouse-color]",
|
|
8
|
+
create: (e) => {
|
|
9
|
+
const r = s.createCircle(n(e.state), "transparent");
|
|
10
|
+
return s.applyStyles(r, {
|
|
11
|
+
zIndex: g.FOLLOWER,
|
|
12
|
+
mixBlendMode: t.mixBlendMode || "difference",
|
|
13
|
+
borderStyle: "solid",
|
|
14
|
+
transition: "opacity 0.2s ease",
|
|
15
|
+
boxSizing: "border-box"
|
|
16
|
+
}), r;
|
|
17
|
+
},
|
|
18
|
+
update: (e, r) => {
|
|
19
|
+
const a = n(e.state), l = e.state.interaction.color || i(e.state);
|
|
20
|
+
s.applyStyles(r, {
|
|
21
|
+
width: `${a}px`,
|
|
22
|
+
height: `${a}px`,
|
|
23
|
+
borderColor: l,
|
|
24
|
+
borderWidth: `${c(e.state)}px`,
|
|
25
|
+
opacity: String(d(e.state)),
|
|
26
|
+
borderRadius: "50%"
|
|
27
|
+
});
|
|
28
|
+
const { x: f, y: m } = e.state.smooth;
|
|
29
|
+
s.setTransform(r, f, m);
|
|
30
|
+
}
|
|
16
31
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let a = c(t.state);
|
|
20
|
-
t.state.interaction.color && (a = t.state.interaction.color), r.setStyle(e, "width", `${n}px`), r.setStyle(e, "height", `${n}px`), r.setStyle(e, "borderRadius", "50%"), r.setStyle(e, "borderColor", a), r.setStyle(e, "borderWidth", `${d(t.state)}px`), r.setStyle(e, "opacity", String(l(t.state)));
|
|
21
|
-
const { x: y, y: f } = t.state.smooth;
|
|
22
|
-
r.setTransform(e, y, f);
|
|
23
|
-
}
|
|
24
|
-
}, o);
|
|
32
|
+
t
|
|
33
|
+
);
|
|
25
34
|
};
|
|
26
35
|
export {
|
|
27
|
-
|
|
36
|
+
b as Ring
|
|
28
37
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.SupermouseRing={},o.SupermouseUtils))})(this,(function(o,e){"use strict";const d=(r={})=>{const i=e.normalize(r.size,20),a=e.normalize(r.color,"#ffffff"),c=e.normalize(r.borderWidth,2),f=e.normalize(r.opacity,1);return e.definePlugin({name:r.name||"ring",selector:"[data-supermouse-color]",create:t=>{const n=e.dom.createCircle(i(t.state),"transparent");return e.dom.applyStyles(n,{zIndex:e.Layers.FOLLOWER,mixBlendMode:r.mixBlendMode||"difference",borderStyle:"solid",transition:"opacity 0.2s ease",boxSizing:"border-box"}),n},update:(t,n)=>{const s=i(t.state),m=t.state.interaction.color||a(t.state);e.dom.applyStyles(n,{width:`${s}px`,height:`${s}px`,borderColor:m,borderWidth:`${c(t.state)}px`,opacity:String(f(t.state)),borderRadius:"50%"});const{x:l,y:u}=t.state.smooth;e.dom.setTransform(n,l,u)}},r)};o.Ring=d,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|
package/meta.json
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
{
|
|
2
|
+
"id": "ring",
|
|
3
|
+
"name": "Ring",
|
|
4
|
+
"package": "@supermousejs/ring",
|
|
5
|
+
"description": "Adds a lagging outer ring. Simple and performant.",
|
|
6
|
+
"code": "app.use(Ring({ size: 32, color: '#000' }));",
|
|
7
|
+
"recipeId": "magnetic-button",
|
|
8
|
+
"icon": "ring",
|
|
9
|
+
"options": [
|
|
10
|
+
{
|
|
11
|
+
"name": "size",
|
|
12
|
+
"type": "number",
|
|
13
|
+
"default": "20",
|
|
14
|
+
"description": "Diameter of the ring in pixels.",
|
|
15
|
+
"reactive": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "color",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"default": "'#ffffff'",
|
|
21
|
+
"description": "Border color.",
|
|
22
|
+
"reactive": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "borderWidth",
|
|
26
|
+
"type": "number",
|
|
27
|
+
"default": "2",
|
|
28
|
+
"description": "Stroke width in pixels.",
|
|
29
|
+
"reactive": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "opacity",
|
|
33
|
+
"type": "number",
|
|
34
|
+
"default": "1",
|
|
35
|
+
"description": "Opacity level (0-1).",
|
|
36
|
+
"reactive": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "mixBlendMode",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"default": "'difference'",
|
|
42
|
+
"description": "CSS blend mode.",
|
|
43
|
+
"reactive": false
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/ring",
|
|
3
|
-
"version": "2.
|
|
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,14 +8,23 @@
|
|
|
8
8
|
"url": "https://github.com/Whitestar14/supermouse-js",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@supermousejs/utils": "2.
|
|
11
|
+
"@supermousejs/utils": "2.2.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@supermousejs/core": "2.0
|
|
14
|
+
"@supermousejs/core": "2.1.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@supermousejs/core": "2.0
|
|
17
|
+
"@supermousejs/core": "2.1.0"
|
|
18
18
|
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Whitestar14/supermouse-js.git",
|
|
22
|
+
"directory": "packages/core"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Whitestar14/supermouse-js/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Whitestar14/supermouse-js/tree/main/packages/ring#readme",
|
|
19
28
|
"exports": {
|
|
20
29
|
".": {
|
|
21
30
|
"types": "./dist/index.d.ts",
|
package/src/index.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import type { ValueOrGetter } from
|
|
2
|
-
import { definePlugin, normalize, dom, Layers } from
|
|
3
|
-
|
|
4
|
-
export interface RingOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
isEnabled?: boolean;
|
|
7
|
-
size?: ValueOrGetter<number>;
|
|
8
|
-
color?: ValueOrGetter<string>;
|
|
9
|
-
borderWidth?: ValueOrGetter<number>;
|
|
10
|
-
opacity?: ValueOrGetter<number>;
|
|
11
|
-
mixBlendMode?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Ring = (options: RingOptions = {}) => {
|
|
15
|
-
const getSize = normalize(options.size, 20);
|
|
16
|
-
const getColor = normalize(options.color,
|
|
17
|
-
const getBorder = normalize(options.borderWidth, 2);
|
|
18
|
-
const getOpacity = normalize(options.opacity, 1);
|
|
19
|
-
|
|
20
|
-
return definePlugin<HTMLDivElement, RingOptions>(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
1
|
+
import type { ValueOrGetter, Supermouse } from "@supermousejs/core";
|
|
2
|
+
import { definePlugin, normalize, dom, Layers } from "@supermousejs/utils";
|
|
3
|
+
|
|
4
|
+
export interface RingOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
isEnabled?: boolean;
|
|
7
|
+
size?: ValueOrGetter<number>;
|
|
8
|
+
color?: ValueOrGetter<string>;
|
|
9
|
+
borderWidth?: ValueOrGetter<number>;
|
|
10
|
+
opacity?: ValueOrGetter<number>;
|
|
11
|
+
mixBlendMode?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Ring = (options: RingOptions = {}) => {
|
|
15
|
+
const getSize = normalize(options.size, 20);
|
|
16
|
+
const getColor = normalize(options.color, "#ffffff");
|
|
17
|
+
const getBorder = normalize(options.borderWidth, 2);
|
|
18
|
+
const getOpacity = normalize(options.opacity, 1);
|
|
19
|
+
|
|
20
|
+
return definePlugin<HTMLDivElement, RingOptions>(
|
|
21
|
+
{
|
|
22
|
+
name: options.name || "ring",
|
|
23
|
+
selector: "[data-supermouse-color]",
|
|
24
|
+
|
|
25
|
+
create: (app: Supermouse) => {
|
|
26
|
+
const el = dom.createCircle(getSize(app.state), "transparent");
|
|
27
|
+
dom.applyStyles(el, {
|
|
28
|
+
zIndex: Layers.FOLLOWER,
|
|
29
|
+
mixBlendMode: options.mixBlendMode || "difference",
|
|
30
|
+
borderStyle: "solid",
|
|
31
|
+
transition: "opacity 0.2s ease",
|
|
32
|
+
boxSizing: "border-box"
|
|
33
|
+
});
|
|
34
|
+
return el;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
update: (app: Supermouse, el: HTMLDivElement) => {
|
|
38
|
+
const size = getSize(app.state);
|
|
39
|
+
const color = app.state.interaction.color || getColor(app.state);
|
|
40
|
+
|
|
41
|
+
dom.applyStyles(el, {
|
|
42
|
+
width: `${size}px`,
|
|
43
|
+
height: `${size}px`,
|
|
44
|
+
borderColor: color,
|
|
45
|
+
borderWidth: `${getBorder(app.state)}px`,
|
|
46
|
+
opacity: String(getOpacity(app.state)),
|
|
47
|
+
borderRadius: "50%"
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const { x, y } = app.state.smooth;
|
|
51
|
+
dom.setTransform(el, x, y);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
options
|
|
55
|
+
);
|
|
56
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.
|
|
3
|
-
"include": [
|
|
4
|
-
|
|
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
|
|
2
|
-
import dts from
|
|
3
|
-
import path from
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
build: {
|
|
7
|
-
lib: {
|
|
8
|
-
entry: path.resolve(__dirname,
|
|
9
|
-
name:
|
|
10
|
-
fileName: (format) => format ===
|
|
11
|
-
},
|
|
12
|
-
rollupOptions: {
|
|
13
|
-
external: [
|
|
14
|
-
output: {
|
|
15
|
-
globals: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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: "SupermouseRing",
|
|
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
|
+
});
|