@supermousejs/text 2.2.0 → 2.3.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 +90 -82
- package/dist/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/index.ts +62 -62
- package/tsconfig.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,82 +1,90 @@
|
|
|
1
|
-
# @supermousejs/text
|
|
2
|
-
|
|
3
|
-
## 2.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- @supermousejs/utils@2.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- Updated dependencies [
|
|
43
|
-
- @supermousejs/utils@2.0
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- Updated dependencies
|
|
51
|
-
- @supermousejs/
|
|
52
|
-
- @supermousejs/
|
|
53
|
-
|
|
54
|
-
## 2.0.
|
|
55
|
-
|
|
56
|
-
### Patch Changes
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
- @supermousejs/utils@2.0.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
- @supermousejs/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
# @supermousejs/text
|
|
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/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/text",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"author": "O.S David",
|
|
5
5
|
"url": "https://github.com/Whitestar14/supermouse-js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@supermousejs/utils": "2.
|
|
8
|
+
"@supermousejs/utils": "2.3.0"
|
|
9
9
|
},
|
|
10
10
|
"main": "dist/index.umd.js",
|
|
11
11
|
"module": "dist/index.mjs",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@supermousejs/core": "2.
|
|
14
|
+
"@supermousejs/core": "2.2.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@supermousejs/core": "2.
|
|
17
|
+
"@supermousejs/core": "2.2.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
package/src/index.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import type { Supermouse } from "@supermousejs/core";
|
|
2
|
-
import { definePlugin, dom, Layers, Easings } from "@supermousejs/utils";
|
|
3
|
-
|
|
4
|
-
export interface TextOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
isEnabled?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
offset?: [number, number];
|
|
9
|
-
duration?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Text = (options: TextOptions = {}) => {
|
|
13
|
-
const className = options.className || "supermouse-text";
|
|
14
|
-
const [offX, offY] = options.offset || [0, 24];
|
|
15
|
-
const duration = options.duration || 200;
|
|
16
|
-
|
|
17
|
-
let textNode: HTMLSpanElement;
|
|
18
|
-
|
|
19
|
-
return definePlugin<HTMLDivElement, TextOptions>(
|
|
20
|
-
{
|
|
21
|
-
name: "text",
|
|
22
|
-
selector: "[data-supermouse-text]",
|
|
23
|
-
|
|
24
|
-
create: () => {
|
|
25
|
-
const el = dom.createActor("div") as HTMLDivElement;
|
|
26
|
-
|
|
27
|
-
dom.applyStyles(el, {
|
|
28
|
-
zIndex: Layers.OVERLAY,
|
|
29
|
-
opacity: "0",
|
|
30
|
-
transition: `opacity ${duration}ms ${Easings.SMOOTH}`,
|
|
31
|
-
whiteSpace: "nowrap",
|
|
32
|
-
pointerEvents: "none"
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (className) {
|
|
36
|
-
el.classList.add(...className.split(" ").filter(Boolean));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
textNode = document.createElement("span");
|
|
40
|
-
el.appendChild(textNode);
|
|
41
|
-
|
|
42
|
-
dom.setTransform(el, -100, -100);
|
|
43
|
-
return el;
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
update: (app: Supermouse, el: HTMLDivElement) => {
|
|
47
|
-
const text = app.state.interaction.text;
|
|
48
|
-
|
|
49
|
-
if (app.state.isHover && text) {
|
|
50
|
-
textNode.innerText = text;
|
|
51
|
-
dom.setStyle(el, "opacity", "1");
|
|
52
|
-
|
|
53
|
-
const { x, y } = app.state.smooth;
|
|
54
|
-
dom.setTransform(el, x + offX, y + offY);
|
|
55
|
-
} else {
|
|
56
|
-
dom.setStyle(el, "opacity", "0");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
options
|
|
61
|
-
);
|
|
62
|
-
};
|
|
1
|
+
import type { Supermouse } from "@supermousejs/core";
|
|
2
|
+
import { definePlugin, dom, Layers, Easings } from "@supermousejs/utils";
|
|
3
|
+
|
|
4
|
+
export interface TextOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
isEnabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
offset?: [number, number];
|
|
9
|
+
duration?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Text = (options: TextOptions = {}) => {
|
|
13
|
+
const className = options.className || "supermouse-text";
|
|
14
|
+
const [offX, offY] = options.offset || [0, 24];
|
|
15
|
+
const duration = options.duration || 200;
|
|
16
|
+
|
|
17
|
+
let textNode: HTMLSpanElement;
|
|
18
|
+
|
|
19
|
+
return definePlugin<HTMLDivElement, TextOptions>(
|
|
20
|
+
{
|
|
21
|
+
name: "text",
|
|
22
|
+
selector: "[data-supermouse-text]",
|
|
23
|
+
|
|
24
|
+
create: () => {
|
|
25
|
+
const el = dom.createActor("div") as HTMLDivElement;
|
|
26
|
+
|
|
27
|
+
dom.applyStyles(el, {
|
|
28
|
+
zIndex: Layers.OVERLAY,
|
|
29
|
+
opacity: "0",
|
|
30
|
+
transition: `opacity ${duration}ms ${Easings.SMOOTH}`,
|
|
31
|
+
whiteSpace: "nowrap",
|
|
32
|
+
pointerEvents: "none"
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (className) {
|
|
36
|
+
el.classList.add(...className.split(" ").filter(Boolean));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
textNode = document.createElement("span");
|
|
40
|
+
el.appendChild(textNode);
|
|
41
|
+
|
|
42
|
+
dom.setTransform(el, -100, -100);
|
|
43
|
+
return el;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
update: (app: Supermouse, el: HTMLDivElement) => {
|
|
47
|
+
const text = app.state.interaction.text;
|
|
48
|
+
|
|
49
|
+
if (app.state.isHover && text) {
|
|
50
|
+
textNode.innerText = text;
|
|
51
|
+
dom.setStyle(el, "opacity", "1");
|
|
52
|
+
|
|
53
|
+
const { x, y } = app.state.smooth;
|
|
54
|
+
dom.setTransform(el, x + offX, y + offY);
|
|
55
|
+
} else {
|
|
56
|
+
dom.setStyle(el, "opacity", "0");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
options
|
|
61
|
+
);
|
|
62
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.plugin.json",
|
|
3
|
-
"include": ["src"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.plugin.json",
|
|
3
|
+
"include": ["src"]
|
|
4
|
+
}
|