@studiometa/ui 0.2.2 → 0.2.3
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.
|
@@ -54,12 +54,17 @@ var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_
|
|
|
54
54
|
this.deltaY = props.delta.y;
|
|
55
55
|
}
|
|
56
56
|
ticked() {
|
|
57
|
-
this.translateX -= Math.abs(this.deltaY) + 1;
|
|
57
|
+
this.translateX -= (Math.abs(this.deltaY) + 1) * this.$options.sensitivity;
|
|
58
58
|
this.transform.translateX = (0, import_utils.damp)(this.translateX, this.transform.translateX, 0.25);
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (this.$options.skew) {
|
|
60
|
+
this.transform.skewX = (0, import_utils.damp)((0, import_utils.clamp)(this.deltaY / 20 * -1, -0.5, 0.5) * this.$options.skewSensitivity, this.transform.skewX, 0.25);
|
|
61
|
+
}
|
|
62
|
+
if (this.translateX <= this.width * -1) {
|
|
63
|
+
this.translateX = 0;
|
|
64
|
+
this.transform.translateX += this.width;
|
|
65
|
+
} else if (this.$options.sensitivity < 0 && this.translateX >= this.width) {
|
|
61
66
|
this.translateX = 0;
|
|
62
|
-
this.transform.translateX
|
|
67
|
+
this.transform.translateX -= this.width;
|
|
63
68
|
}
|
|
64
69
|
(0, import_utils.nextFrame)(() => {
|
|
65
70
|
this.$refs.target.style.transform = (0, import_utils.matrix)(this.transform) + " translateZ(0px)";
|
|
@@ -68,7 +73,18 @@ var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_
|
|
|
68
73
|
};
|
|
69
74
|
__publicField(LargeText, "config", {
|
|
70
75
|
name: "LargeText",
|
|
71
|
-
refs: ["target"]
|
|
76
|
+
refs: ["target"],
|
|
77
|
+
options: {
|
|
78
|
+
skew: Boolean,
|
|
79
|
+
sensitivity: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 1
|
|
82
|
+
},
|
|
83
|
+
skewSensitivity: {
|
|
84
|
+
type: Number,
|
|
85
|
+
default: 1
|
|
86
|
+
}
|
|
87
|
+
}
|
|
72
88
|
});
|
|
73
89
|
module.exports = __toCommonJS(LargeText_exports);
|
|
74
90
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {LargeText & {
|
|
2
|
+
* @typedef {LargeText & {
|
|
3
|
+
* $refs: { target: HTMLElement },
|
|
4
|
+
* $options: {
|
|
5
|
+
* skew: boolean,
|
|
6
|
+
* sensitivity: number,
|
|
7
|
+
* skewSensitivity: number,
|
|
8
|
+
* }
|
|
9
|
+
* }} LargeTextInterface
|
|
3
10
|
*/
|
|
4
11
|
/**
|
|
5
12
|
* Large text class.
|
|
@@ -11,6 +18,17 @@ export default class LargeText extends Base {
|
|
|
11
18
|
static config: {
|
|
12
19
|
name: string;
|
|
13
20
|
refs: string[];
|
|
21
|
+
options: {
|
|
22
|
+
skew: BooleanConstructor;
|
|
23
|
+
sensitivity: {
|
|
24
|
+
type: NumberConstructor;
|
|
25
|
+
default: number;
|
|
26
|
+
};
|
|
27
|
+
skewSensitivity: {
|
|
28
|
+
type: NumberConstructor;
|
|
29
|
+
default: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
14
32
|
};
|
|
15
33
|
/**
|
|
16
34
|
* Translate X.
|
|
@@ -67,5 +85,10 @@ export type LargeTextInterface = LargeText & {
|
|
|
67
85
|
$refs: {
|
|
68
86
|
target: HTMLElement;
|
|
69
87
|
};
|
|
88
|
+
$options: {
|
|
89
|
+
skew: boolean;
|
|
90
|
+
sensitivity: number;
|
|
91
|
+
skewSensitivity: number;
|
|
92
|
+
};
|
|
70
93
|
};
|
|
71
94
|
import { Base } from "@studiometa/js-toolkit";
|
|
@@ -27,12 +27,17 @@ class LargeText extends withMountWhenInView(Base, { rootMargin: "50%" }) {
|
|
|
27
27
|
this.deltaY = props.delta.y;
|
|
28
28
|
}
|
|
29
29
|
ticked() {
|
|
30
|
-
this.translateX -= Math.abs(this.deltaY) + 1;
|
|
30
|
+
this.translateX -= (Math.abs(this.deltaY) + 1) * this.$options.sensitivity;
|
|
31
31
|
this.transform.translateX = damp(this.translateX, this.transform.translateX, 0.25);
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (this.$options.skew) {
|
|
33
|
+
this.transform.skewX = damp(clamp(this.deltaY / 20 * -1, -0.5, 0.5) * this.$options.skewSensitivity, this.transform.skewX, 0.25);
|
|
34
|
+
}
|
|
35
|
+
if (this.translateX <= this.width * -1) {
|
|
36
|
+
this.translateX = 0;
|
|
37
|
+
this.transform.translateX += this.width;
|
|
38
|
+
} else if (this.$options.sensitivity < 0 && this.translateX >= this.width) {
|
|
34
39
|
this.translateX = 0;
|
|
35
|
-
this.transform.translateX
|
|
40
|
+
this.transform.translateX -= this.width;
|
|
36
41
|
}
|
|
37
42
|
nextFrame(() => {
|
|
38
43
|
this.$refs.target.style.transform = matrix(this.transform) + " translateZ(0px)";
|
|
@@ -41,7 +46,18 @@ class LargeText extends withMountWhenInView(Base, { rootMargin: "50%" }) {
|
|
|
41
46
|
}
|
|
42
47
|
__publicField(LargeText, "config", {
|
|
43
48
|
name: "LargeText",
|
|
44
|
-
refs: ["target"]
|
|
49
|
+
refs: ["target"],
|
|
50
|
+
options: {
|
|
51
|
+
skew: Boolean,
|
|
52
|
+
sensitivity: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: 1
|
|
55
|
+
},
|
|
56
|
+
skewSensitivity: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default: 1
|
|
59
|
+
}
|
|
60
|
+
}
|
|
45
61
|
});
|
|
46
62
|
export {
|
|
47
63
|
LargeText as default
|