geekin-devtoys 0.3.8 → 0.3.9
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/lib/GBubble/index.js +1 -2
- package/lib/GBubble/index.mjs +3 -210
- package/lib/GBubble-C3cM9Put.mjs +216 -0
- package/lib/GBubble-Dph0YDkU.js +2 -0
- package/lib/GButton/index.js +1 -1
- package/lib/GButton/index.mjs +81 -5
- package/lib/GButton/style.css +1 -0
- package/lib/GCard/index.js +1 -1
- package/lib/GCard/index.mjs +1 -1
- package/lib/GDialog/index.js +1 -1
- package/lib/GDialog/index.mjs +33 -34
- package/lib/GInput/index.js +1 -0
- package/lib/GInput/index.mjs +145 -0
- package/lib/GInput/style.css +1 -0
- package/lib/GInput.d.ts +1 -0
- package/lib/GInputTreeTag/index.js +1 -1
- package/lib/GInputTreeTag/index.mjs +77 -75
- package/lib/GInputTreeTag/style.css +1 -1
- package/lib/GPie3D/index.js +1 -1
- package/lib/GPie3D/index.mjs +1 -1
- package/lib/GProgress/index.js +1 -1
- package/lib/GProgress/index.mjs +1 -1
- package/lib/GRing/index.js +1 -1
- package/lib/GRing/index.mjs +1 -1
- package/lib/GScroller/index.js +1 -1
- package/lib/GScroller/index.mjs +135 -152
- package/lib/GShinyText/index.js +1 -1
- package/lib/GShinyText/index.mjs +45 -119
- package/lib/GSteps/index.js +1 -1
- package/lib/GSteps/index.mjs +89 -43
- package/lib/GSteps/style.css +1 -1
- package/lib/GTable/index.js +1 -1
- package/lib/GTable/index.mjs +1 -1
- package/lib/GTag/index.js +1 -0
- package/lib/GTag/index.mjs +73 -0
- package/lib/GTag.d.ts +1 -0
- package/lib/GVideo/index.js +2 -2
- package/lib/GVideo/index.mjs +1 -1
- package/lib/assets/GTag.css +1 -0
- package/lib/components/GInput/index.d.ts +64 -0
- package/lib/components/GInputTreeTag/index.d.ts +15 -23
- package/lib/components/GTag/index.d.ts +38 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +38 -33
- package/lib/index/style.css +25 -1
- package/lib/index.d.ts +3 -1
- package/package.json +12 -20
- package/lib/AnimatePresence-26Wy0TGN.js +0 -9
- package/lib/AnimatePresence-nl0c23TZ.mjs +0 -136
- package/lib/_plugin-vue_export-helper-BHFhmbuH.js +0 -1
- package/lib/_plugin-vue_export-helper-CHgC5LLL.mjs +0 -9
- package/lib/index-B8Ap0044.js +0 -1
- package/lib/index-Bbr5fWvI.mjs +0 -5158
- package/lib/index-CWxEZ_zc.mjs +0 -74
- package/lib/index-Q0Ej8RIj.js +0 -1
package/lib/GScroller/index.mjs
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function Me(S, E) {
|
|
6
|
-
const p = n(!1);
|
|
7
|
-
return de((l) => {
|
|
8
|
-
const T = W(E) || {}, { once: H } = T, w = ke(S);
|
|
9
|
-
if (!w || H && p.value) return;
|
|
10
|
-
const g = Se(w, () => (p.value = !0, H ? void 0 : () => {
|
|
11
|
-
p.value = !1;
|
|
12
|
-
}), {
|
|
13
|
-
...T,
|
|
14
|
-
root: W(T.root)
|
|
15
|
-
});
|
|
16
|
-
l(() => {
|
|
17
|
-
g();
|
|
18
|
-
});
|
|
19
|
-
}, { flush: "post" }), p;
|
|
20
|
-
}
|
|
21
|
-
const Ce = ["onMouseenter", "onClick"], He = { class: "g-scroller__item-text" }, be = { class: "g-scroller__item-text" }, ae = 80, Ie = 10, $e = /* @__PURE__ */ ee({
|
|
1
|
+
import { defineComponent as j, ref as n, h as de, useSlots as fe, computed as H, onMounted as ve, onUnmounted as ge, watch as D, nextTick as L, createElementBlock as c, openBlock as r, normalizeStyle as S, normalizeClass as h, createElementVNode as m, createCommentVNode as J, Fragment as _, renderList as N, renderSlot as Q, toDisplayString as Z, createBlock as pe, unref as he, withCtx as _e } from "vue";
|
|
2
|
+
import { useInView as ye, motion as ke } from "motion-v";
|
|
3
|
+
import { _ as Se } from "../GBubble-C3cM9Put.mjs";
|
|
4
|
+
const Te = ["onMouseenter", "onClick"], Me = { class: "g-scroller__item-text" }, we = { class: "g-scroller__item-text" }, x = 80, Ce = 10, He = /* @__PURE__ */ j({
|
|
22
5
|
__name: "index",
|
|
23
6
|
props: {
|
|
24
7
|
items: { default: () => [] },
|
|
@@ -37,8 +20,8 @@ const Ce = ["onMouseenter", "onClick"], He = { class: "g-scroller__item-text" },
|
|
|
37
20
|
seamlessPauseOnHover: { type: Boolean, default: !0 }
|
|
38
21
|
},
|
|
39
22
|
emits: ["itemSelected"],
|
|
40
|
-
setup(
|
|
41
|
-
const
|
|
23
|
+
setup(b, { emit: ee }) {
|
|
24
|
+
const le = j({
|
|
42
25
|
name: "AnimatedItem",
|
|
43
26
|
props: {
|
|
44
27
|
index: { type: Number, required: !0 },
|
|
@@ -47,12 +30,12 @@ const Ce = ["onMouseenter", "onClick"], He = { class: "g-scroller__item-text" },
|
|
|
47
30
|
instant: { type: Boolean, default: !1 }
|
|
48
31
|
},
|
|
49
32
|
emits: ["mouseenter", "click"],
|
|
50
|
-
setup(e, { slots: a, emit:
|
|
51
|
-
const
|
|
52
|
-
return () =>
|
|
53
|
-
|
|
33
|
+
setup(e, { slots: a, emit: s }) {
|
|
34
|
+
const t = n(null), u = ye(t, { amount: 0.5, once: !1 });
|
|
35
|
+
return () => de(
|
|
36
|
+
ke.div,
|
|
54
37
|
{
|
|
55
|
-
ref:
|
|
38
|
+
ref: t,
|
|
56
39
|
"data-index": e.index,
|
|
57
40
|
style: { marginBottom: "1rem", cursor: "pointer" },
|
|
58
41
|
initial: { x: -24, opacity: 0 },
|
|
@@ -62,197 +45,197 @@ const Ce = ["onMouseenter", "onClick"], He = { class: "g-scroller__item-text" },
|
|
|
62
45
|
delay: Math.min(e.index * e.stagger, 0.3),
|
|
63
46
|
ease: "easeOut"
|
|
64
47
|
},
|
|
65
|
-
onMouseenter: (v) =>
|
|
66
|
-
onClick: (v) =>
|
|
48
|
+
onMouseenter: (v) => s("mouseenter", v),
|
|
49
|
+
onClick: (v) => s("click", v)
|
|
67
50
|
},
|
|
68
51
|
a.default?.()
|
|
69
52
|
);
|
|
70
53
|
}
|
|
71
|
-
}), l =
|
|
72
|
-
let
|
|
73
|
-
const
|
|
74
|
-
let
|
|
75
|
-
const
|
|
54
|
+
}), l = b, se = ee, te = fe(), F = H(() => !!te.default), E = n(null), y = n(l.initialSelectedIndex), G = n(0), P = n(1), Y = n(0), k = n(0), T = n(!1);
|
|
55
|
+
let d = null;
|
|
56
|
+
const M = n(!1);
|
|
57
|
+
let V = 0, $ = 0, f = null;
|
|
58
|
+
const W = n(null), q = n(null), ae = H(
|
|
76
59
|
() => l.seamless && l.items.length > 0 ? [...l.items, ...l.items] : l.items
|
|
77
|
-
), o = n(0),
|
|
78
|
-
let
|
|
79
|
-
const
|
|
60
|
+
), o = n(0), w = n(!1), i = n(0), I = n(!1);
|
|
61
|
+
let g = null, p = 0;
|
|
62
|
+
const ne = H(() => {
|
|
80
63
|
const e = {};
|
|
81
64
|
return l.height != null && l.height !== "" && (e.height = typeof l.height == "number" ? `${l.height}px` : String(l.height)), e;
|
|
82
|
-
}),
|
|
65
|
+
}), oe = H(() => ({
|
|
83
66
|
transform: `translateY(${o.value}px)`
|
|
84
67
|
}));
|
|
85
|
-
function
|
|
86
|
-
return Math.min(Math.max(e, a),
|
|
68
|
+
function re(e, a, s) {
|
|
69
|
+
return Math.min(Math.max(e, a), s);
|
|
87
70
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
const a = e.target, { scrollTop:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, 150),
|
|
97
|
-
const
|
|
98
|
-
|
|
71
|
+
const z = (e) => {
|
|
72
|
+
y.value = e;
|
|
73
|
+
}, U = (e, a) => {
|
|
74
|
+
y.value = a, se("itemSelected", e, a);
|
|
75
|
+
}, ie = (e) => {
|
|
76
|
+
const a = e.target, { scrollTop: s, scrollHeight: t, clientHeight: u } = a, v = performance.now();
|
|
77
|
+
$ > 0 && Math.abs(s - V) / (v - $) > Ce && (M.value = !0), V = s, $ = v, f && clearTimeout(f), f = setTimeout(() => {
|
|
78
|
+
M.value = !1;
|
|
79
|
+
}, 150), G.value = Math.min(s / 50, 1);
|
|
80
|
+
const R = t - (s + u);
|
|
81
|
+
P.value = t <= u ? 0 : Math.min(R / 50, 1);
|
|
99
82
|
};
|
|
100
|
-
function
|
|
101
|
-
const a =
|
|
83
|
+
function ue(e) {
|
|
84
|
+
const a = E.value;
|
|
102
85
|
if (!a) return;
|
|
103
|
-
const { scrollTop:
|
|
104
|
-
if (
|
|
105
|
-
const v =
|
|
106
|
-
if (v && e.deltaY < 0 ||
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
86
|
+
const { scrollTop: s, scrollHeight: t, clientHeight: u } = a;
|
|
87
|
+
if (t <= u) return;
|
|
88
|
+
const v = s <= 0, R = s + u >= t - 1;
|
|
89
|
+
if (v && e.deltaY < 0 || R && e.deltaY > 0) {
|
|
90
|
+
const X = re(k.value - e.deltaY * 0.3, -x, x);
|
|
91
|
+
k.value = X, T.value = !0, d && clearTimeout(d), d = setTimeout(() => {
|
|
92
|
+
k.value = 0, T.value = !1;
|
|
110
93
|
}, 150);
|
|
111
94
|
}
|
|
112
95
|
}
|
|
113
|
-
function
|
|
114
|
-
const e =
|
|
96
|
+
function C() {
|
|
97
|
+
const e = q.value;
|
|
115
98
|
if (!e || l.items.length === 0) {
|
|
116
|
-
i.value = 0,
|
|
99
|
+
i.value = 0, I.value = !1;
|
|
117
100
|
return;
|
|
118
101
|
}
|
|
119
|
-
const a = l.items.length,
|
|
120
|
-
i.value =
|
|
121
|
-
const
|
|
122
|
-
|
|
102
|
+
const a = l.items.length, s = e.children[a];
|
|
103
|
+
i.value = s ? s.offsetTop : e.scrollHeight / 2;
|
|
104
|
+
const t = W.value;
|
|
105
|
+
I.value = t ? i.value > t.clientHeight : !0;
|
|
123
106
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
const a = e -
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
l.seamlessDirection === "down" ? (o.value +=
|
|
107
|
+
function K(e) {
|
|
108
|
+
p === 0 && (p = e);
|
|
109
|
+
const a = e - p;
|
|
110
|
+
if (p = e, !w.value && i.value > 0 && l.items.length > 0) {
|
|
111
|
+
const s = l.seamlessSpeed * a / 1e3;
|
|
112
|
+
l.seamlessDirection === "down" ? (o.value += s, o.value >= 0 && (o.value -= i.value)) : (o.value -= s, o.value <= -i.value && (o.value += i.value));
|
|
130
113
|
}
|
|
131
|
-
|
|
114
|
+
g = requestAnimationFrame(K);
|
|
115
|
+
}
|
|
116
|
+
function B() {
|
|
117
|
+
g == null && (p = 0, g = requestAnimationFrame(K));
|
|
132
118
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
119
|
+
function O() {
|
|
120
|
+
g != null && (cancelAnimationFrame(g), g = null), p = 0;
|
|
135
121
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
122
|
+
function ce() {
|
|
123
|
+
l.seamlessPauseOnHover && (w.value = !0);
|
|
138
124
|
}
|
|
139
125
|
function me() {
|
|
140
|
-
l.seamlessPauseOnHover && (
|
|
141
|
-
}
|
|
142
|
-
function fe() {
|
|
143
|
-
l.seamlessPauseOnHover && ($.value = !1);
|
|
126
|
+
l.seamlessPauseOnHover && (w.value = !1);
|
|
144
127
|
}
|
|
145
|
-
return
|
|
146
|
-
l.seamless && !l.loading && (
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
}),
|
|
128
|
+
return ve(() => {
|
|
129
|
+
l.seamless && !l.loading && (C(), o.value = l.seamlessDirection === "down" ? -i.value : 0, B());
|
|
130
|
+
}), ge(() => {
|
|
131
|
+
O(), d && (clearTimeout(d), d = null), f && (clearTimeout(f), f = null);
|
|
132
|
+
}), D(
|
|
150
133
|
() => l.items,
|
|
151
134
|
() => {
|
|
152
|
-
l.seamless &&
|
|
153
|
-
|
|
154
|
-
}),
|
|
135
|
+
l.seamless && L(() => {
|
|
136
|
+
C(), o.value = l.seamlessDirection === "down" ? -i.value : 0;
|
|
137
|
+
}), Y.value++, y.value = -1;
|
|
155
138
|
}
|
|
156
|
-
),
|
|
139
|
+
), D(
|
|
157
140
|
() => l.seamless,
|
|
158
141
|
(e) => {
|
|
159
|
-
e && !l.loading ?
|
|
160
|
-
|
|
161
|
-
}) : (
|
|
142
|
+
e && !l.loading ? L(() => {
|
|
143
|
+
C(), o.value = l.seamlessDirection === "down" ? -i.value : 0, B();
|
|
144
|
+
}) : (O(), o.value = 0, w.value = !1);
|
|
162
145
|
}
|
|
163
|
-
),
|
|
146
|
+
), D(
|
|
164
147
|
() => l.loading,
|
|
165
148
|
(e) => {
|
|
166
|
-
e ? (
|
|
167
|
-
|
|
149
|
+
e ? (k.value = 0, T.value = !1, M.value = !1, O(), d && (clearTimeout(d), d = null), f && (clearTimeout(f), f = null)) : l.seamless && L(() => {
|
|
150
|
+
C(), o.value = l.seamlessDirection === "down" ? -i.value : 0, B();
|
|
168
151
|
});
|
|
169
152
|
}
|
|
170
153
|
), (e, a) => (r(), c("div", {
|
|
171
|
-
class:
|
|
172
|
-
style:
|
|
154
|
+
class: h(["g-scroller", e.className]),
|
|
155
|
+
style: S(ne.value)
|
|
173
156
|
}, [
|
|
174
157
|
e.seamless && !e.loading ? (r(), c("div", {
|
|
175
158
|
key: 0,
|
|
176
159
|
ref_key: "seamlessWrapRef",
|
|
177
|
-
ref:
|
|
160
|
+
ref: W,
|
|
178
161
|
class: "g-scroller__seamless",
|
|
179
|
-
onMouseenter:
|
|
180
|
-
onMouseleave:
|
|
162
|
+
onMouseenter: ce,
|
|
163
|
+
onMouseleave: me
|
|
181
164
|
}, [
|
|
182
165
|
m("div", {
|
|
183
166
|
ref_key: "seamlessTrackRef",
|
|
184
|
-
ref:
|
|
167
|
+
ref: q,
|
|
185
168
|
class: "g-scroller__seamless-track",
|
|
186
|
-
style:
|
|
169
|
+
style: S(oe.value)
|
|
187
170
|
}, [
|
|
188
|
-
(r(!0), c(
|
|
189
|
-
key: `seamless-${
|
|
190
|
-
class:
|
|
171
|
+
(r(!0), c(_, null, N(ae.value, (s, t) => (r(), c("div", {
|
|
172
|
+
key: `seamless-${t}`,
|
|
173
|
+
class: h([
|
|
191
174
|
"g-scroller__item",
|
|
192
175
|
"g-scroller__item--seamless",
|
|
193
|
-
!
|
|
194
|
-
|
|
176
|
+
!F.value && "g-scroller__item--default",
|
|
177
|
+
y.value === t % e.items.length && "g-scroller__item--active",
|
|
195
178
|
e.itemClassName
|
|
196
179
|
]),
|
|
197
|
-
onMouseenter: (u) =>
|
|
198
|
-
onClick: (u) =>
|
|
180
|
+
onMouseenter: (u) => z(t % e.items.length),
|
|
181
|
+
onClick: (u) => U(s, t % e.items.length)
|
|
199
182
|
}, [
|
|
200
|
-
|
|
201
|
-
item:
|
|
202
|
-
index:
|
|
183
|
+
Q(e.$slots, "default", {
|
|
184
|
+
item: s,
|
|
185
|
+
index: t % e.items.length
|
|
203
186
|
}, () => [
|
|
204
|
-
m("p",
|
|
187
|
+
m("p", Me, Z(s), 1)
|
|
205
188
|
], !0)
|
|
206
|
-
], 42,
|
|
189
|
+
], 42, Te))), 128))
|
|
207
190
|
], 4),
|
|
208
|
-
e.showGradients &&
|
|
191
|
+
e.showGradients && I.value ? (r(), c(_, { key: 0 }, [
|
|
209
192
|
a[0] || (a[0] = m("div", { class: "g-scroller__gradient g-scroller__gradient--top" }, null, -1)),
|
|
210
193
|
a[1] || (a[1] = m("div", { class: "g-scroller__gradient g-scroller__gradient--bottom" }, null, -1))
|
|
211
|
-
], 64)) :
|
|
194
|
+
], 64)) : J("", !0)
|
|
212
195
|
], 544)) : e.loading ? (r(), c("div", {
|
|
213
196
|
key: 1,
|
|
214
|
-
class:
|
|
197
|
+
class: h(["g-scroller__list", !e.displayScrollbar && "g-scroller__list--hidden-scrollbar"])
|
|
215
198
|
}, [
|
|
216
|
-
(r(!0), c(
|
|
217
|
-
key: `skeleton-${
|
|
199
|
+
(r(!0), c(_, null, N(e.skeletonCount, (s) => (r(), c("div", {
|
|
200
|
+
key: `skeleton-${s}`,
|
|
218
201
|
class: "g-scroller__skeleton"
|
|
219
202
|
}, a[2] || (a[2] = [
|
|
220
203
|
m("div", { class: "g-scroller__skeleton-line" }, null, -1)
|
|
221
204
|
])))), 128))
|
|
222
|
-
], 2)) : (r(), c(
|
|
205
|
+
], 2)) : (r(), c(_, { key: 2 }, [
|
|
223
206
|
m("div", {
|
|
224
207
|
ref_key: "listRef",
|
|
225
|
-
ref:
|
|
226
|
-
class:
|
|
227
|
-
onScroll:
|
|
228
|
-
onWheel:
|
|
208
|
+
ref: E,
|
|
209
|
+
class: h(["g-scroller__list", !e.displayScrollbar && "g-scroller__list--hidden-scrollbar"]),
|
|
210
|
+
onScroll: ie,
|
|
211
|
+
onWheel: ue
|
|
229
212
|
}, [
|
|
230
213
|
m("div", {
|
|
231
|
-
class:
|
|
232
|
-
style:
|
|
214
|
+
class: h(["g-scroller__content", { "g-scroller__content--pulling": T.value }]),
|
|
215
|
+
style: S({ transform: `translateY(${k.value}px)` })
|
|
233
216
|
}, [
|
|
234
|
-
(r(!0), c(
|
|
235
|
-
key: `${
|
|
236
|
-
index:
|
|
217
|
+
(r(!0), c(_, null, N(e.items, (s, t) => (r(), pe(he(le), {
|
|
218
|
+
key: `${Y.value}-${t}`,
|
|
219
|
+
index: t,
|
|
237
220
|
stagger: e.stagger,
|
|
238
|
-
instant:
|
|
239
|
-
onMouseenter: (u) =>
|
|
240
|
-
onClick: (u) =>
|
|
221
|
+
instant: M.value,
|
|
222
|
+
onMouseenter: (u) => z(t),
|
|
223
|
+
onClick: (u) => U(s, t)
|
|
241
224
|
}, {
|
|
242
|
-
default:
|
|
225
|
+
default: _e(() => [
|
|
243
226
|
m("div", {
|
|
244
|
-
class:
|
|
227
|
+
class: h([
|
|
245
228
|
"g-scroller__item",
|
|
246
|
-
!
|
|
247
|
-
|
|
229
|
+
!F.value && "g-scroller__item--default",
|
|
230
|
+
y.value === t && "g-scroller__item--active",
|
|
248
231
|
e.itemClassName
|
|
249
232
|
])
|
|
250
233
|
}, [
|
|
251
|
-
|
|
252
|
-
item:
|
|
253
|
-
index:
|
|
234
|
+
Q(e.$slots, "default", {
|
|
235
|
+
item: s,
|
|
236
|
+
index: t
|
|
254
237
|
}, () => [
|
|
255
|
-
m("p",
|
|
238
|
+
m("p", we, Z(s), 1)
|
|
256
239
|
], !0)
|
|
257
240
|
], 2)
|
|
258
241
|
]),
|
|
@@ -260,24 +243,24 @@ const Ce = ["onMouseenter", "onClick"], He = { class: "g-scroller__item-text" },
|
|
|
260
243
|
}, 1032, ["index", "stagger", "instant", "onMouseenter", "onClick"]))), 128))
|
|
261
244
|
], 6)
|
|
262
245
|
], 34),
|
|
263
|
-
e.showGradients ? (r(), c(
|
|
246
|
+
e.showGradients ? (r(), c(_, { key: 0 }, [
|
|
264
247
|
m("div", {
|
|
265
248
|
class: "g-scroller__gradient g-scroller__gradient--top",
|
|
266
|
-
style:
|
|
249
|
+
style: S({ opacity: G.value })
|
|
267
250
|
}, null, 4),
|
|
268
251
|
m("div", {
|
|
269
252
|
class: "g-scroller__gradient g-scroller__gradient--bottom",
|
|
270
|
-
style:
|
|
253
|
+
style: S({ opacity: P.value })
|
|
271
254
|
}, null, 4)
|
|
272
|
-
], 64)) :
|
|
255
|
+
], 64)) : J("", !0)
|
|
273
256
|
], 64))
|
|
274
257
|
], 6));
|
|
275
258
|
}
|
|
276
|
-
}),
|
|
277
|
-
|
|
278
|
-
|
|
259
|
+
}), A = /* @__PURE__ */ Se(He, [["__scopeId", "data-v-972060e6"]]);
|
|
260
|
+
A.install = (b) => {
|
|
261
|
+
b.component(A.name, A);
|
|
279
262
|
};
|
|
280
263
|
export {
|
|
281
|
-
|
|
282
|
-
|
|
264
|
+
A as GScroller,
|
|
265
|
+
A as default
|
|
283
266
|
};
|
package/lib/GShinyText/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("motion-v"),i=e.defineComponent({__name:"index",props:{text:{},disabled:{type:Boolean,default:!1},speed:{default:2},className:{default:""},color:{default:"#b5b5b5"},shineColor:{default:"#ffffff"},spread:{default:120},yoyo:{type:Boolean,default:!1},pauseOnHover:{type:Boolean,default:!1},direction:{default:"left"},delay:{default:0}},setup(v){const l=v,p=e.ref(!1),t=f.useMotionValue(0),c=e.ref(0),r=e.ref(null),s=e.ref(l.direction==="left"?1:-1),a=e.computed(()=>l.speed*1e3),y=e.computed(()=>l.delay*1e3);f.useAnimationFrame(o=>{if(l.disabled||p.value){r.value=null;return}if(r.value===null){r.value=o;return}const b=o-r.value;if(r.value=o,c.value+=b,l.yoyo){const u=a.value+y.value,d=u*2,n=c.value%d;if(n<a.value){const m=n/a.value*100;t.set(s.value===1?m:100-m)}else if(n<u)t.set(s.value===1?100:0);else if(n<u+a.value){const g=100-(n-u)/a.value*100;t.set(s.value===1?g:100-g)}else t.set(s.value===1?0:100)}else{const u=a.value+y.value,d=c.value%u;if(d<a.value){const n=d/a.value*100;t.set(s.value===1?n:100-n)}else t.set(s.value===1?100:0)}}),e.watch(()=>l.direction,()=>{s.value=l.direction==="left"?1:-1,c.value=0,t.set(0)},{immediate:!0});const k=f.useTransform(t,o=>`${150-o*2}% center`),T=()=>{l.pauseOnHover&&(p.value=!0)},C=()=>{l.pauseOnHover&&(p.value=!1)},h=e.computed(()=>({backgroundImage:`linear-gradient(${l.spread}deg, ${l.color} 0%, ${l.color} 35%, ${l.shineColor} 50%, ${l.color} 65%, ${l.color} 100%)`,backgroundSize:"200% auto",WebkitBackgroundClip:"text",backgroundClip:"text",WebkitTextFillColor:"transparent"}));return(o,b)=>(e.openBlock(),e.createBlock(e.unref(f.Motion),{tag:"span",class:e.normalizeClass(["inline-block",o.className]),style:e.normalizeStyle({...h.value,backgroundPosition:e.unref(k)}),onMouseenter:T,onMouseleave:C},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.text),1)]),_:1},8,["class","style"]))}});i.install=v=>{v.component(i.name,i)};exports.GShinyText=i;exports.default=i;
|
package/lib/GShinyText/index.mjs
CHANGED
|
@@ -1,80 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const e = !Array.isArray(t[0]), s = e ? 0 : -1, o = t[0 + s], l = t[1 + s], n = t[2 + s], r = t[3 + s], a = q(l, n, r);
|
|
5
|
-
return e ? a(o) : a;
|
|
6
|
-
}
|
|
7
|
-
function K(t) {
|
|
8
|
-
let e = 0;
|
|
9
|
-
const s = ({ timestamp: l, delta: n }) => {
|
|
10
|
-
e || (e = l), t(l - e, n);
|
|
11
|
-
}, o = () => $(s);
|
|
12
|
-
z(() => {
|
|
13
|
-
o(), k.update(s, !0);
|
|
14
|
-
}), S(() => o()), k.update(s, !0);
|
|
15
|
-
}
|
|
16
|
-
function D(t) {
|
|
17
|
-
const e = C(t()), s = () => e.set(t()), o = () => k.preRender(s, !1, !0);
|
|
18
|
-
let l;
|
|
19
|
-
const n = (a) => {
|
|
20
|
-
l = a.map((c) => c.on("change", o));
|
|
21
|
-
}, r = () => {
|
|
22
|
-
l.forEach((a) => a()), $(s);
|
|
23
|
-
};
|
|
24
|
-
return E() && S(() => {
|
|
25
|
-
r();
|
|
26
|
-
}), {
|
|
27
|
-
subscribe: n,
|
|
28
|
-
unsubscribe: r,
|
|
29
|
-
value: e,
|
|
30
|
-
updateValue: s
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function Q(t) {
|
|
34
|
-
v.current = [];
|
|
35
|
-
const { value: e, subscribe: s, unsubscribe: o, updateValue: l } = D(t);
|
|
36
|
-
return s(v.current), v.current = void 0, F(() => {
|
|
37
|
-
o(), v.current = [], l(), s(v.current), v.current = void 0;
|
|
38
|
-
}), e;
|
|
39
|
-
}
|
|
40
|
-
function X(t, e, s, o) {
|
|
41
|
-
if (typeof t == "function") return Q(t);
|
|
42
|
-
let l, n;
|
|
43
|
-
if (typeof e == "function")
|
|
44
|
-
n = e, l = Array.isArray(t) ? t : [t];
|
|
45
|
-
else if (M(e)) {
|
|
46
|
-
const a = C(0);
|
|
47
|
-
let c = A(e.value, s, o);
|
|
48
|
-
T(e, (f) => {
|
|
49
|
-
c = A(f, s, o), a.set(a.get() + 1);
|
|
50
|
-
}, { flush: "sync" }), n = (f) => Array.isArray(f) ? c(f[0]) : c(f), l = Array.isArray(t) ? [...t, a] : [t, a];
|
|
51
|
-
} else
|
|
52
|
-
n = A(e, s, o), l = Array.isArray(t) ? t : [t];
|
|
53
|
-
const r = Array.isArray(t) ? B(l, n) : B(l, (a) => n(a[0]));
|
|
54
|
-
if (!Array.isArray(t)) {
|
|
55
|
-
const a = t.accelerate;
|
|
56
|
-
if (a && !a.isTransformed && typeof e != "function" && Array.isArray(s) && o?.clamp !== !1) {
|
|
57
|
-
const c = M(e) ? e.value : e;
|
|
58
|
-
r.accelerate = {
|
|
59
|
-
...a,
|
|
60
|
-
times: c,
|
|
61
|
-
keyframes: s,
|
|
62
|
-
isTransformed: !0
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return r;
|
|
67
|
-
}
|
|
68
|
-
function B(t, e) {
|
|
69
|
-
const s = [], o = () => {
|
|
70
|
-
s.length = 0;
|
|
71
|
-
const r = t.length;
|
|
72
|
-
for (let a = 0; a < r; a++) s[a] = t[a].get();
|
|
73
|
-
return e(s);
|
|
74
|
-
}, { value: l, subscribe: n } = D(o);
|
|
75
|
-
return n(t), l;
|
|
76
|
-
}
|
|
77
|
-
const h = /* @__PURE__ */ H({
|
|
1
|
+
import { defineComponent as $, ref as c, computed as p, watch as B, createBlock as M, openBlock as D, unref as k, normalizeStyle as S, normalizeClass as _, withCtx as z, createTextVNode as H, toDisplayString as N } from "vue";
|
|
2
|
+
import { useMotionValue as O, useAnimationFrame as P, useTransform as R, Motion as w } from "motion-v";
|
|
3
|
+
const m = /* @__PURE__ */ $({
|
|
78
4
|
__name: "index",
|
|
79
5
|
props: {
|
|
80
6
|
text: {},
|
|
@@ -89,76 +15,76 @@ const h = /* @__PURE__ */ H({
|
|
|
89
15
|
direction: { default: "left" },
|
|
90
16
|
delay: { default: 0 }
|
|
91
17
|
},
|
|
92
|
-
setup(
|
|
93
|
-
const e =
|
|
94
|
-
|
|
95
|
-
if (e.disabled ||
|
|
96
|
-
|
|
18
|
+
setup(d) {
|
|
19
|
+
const e = d, f = c(!1), a = O(0), r = c(0), u = c(null), n = c(e.direction === "left" ? 1 : -1), l = p(() => e.speed * 1e3), y = p(() => e.delay * 1e3);
|
|
20
|
+
P((t) => {
|
|
21
|
+
if (e.disabled || f.value) {
|
|
22
|
+
u.value = null;
|
|
97
23
|
return;
|
|
98
24
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
25
|
+
if (u.value === null) {
|
|
26
|
+
u.value = t;
|
|
101
27
|
return;
|
|
102
28
|
}
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
} else if (
|
|
110
|
-
|
|
111
|
-
else if (
|
|
112
|
-
const
|
|
113
|
-
|
|
29
|
+
const b = t - u.value;
|
|
30
|
+
if (u.value = t, r.value += b, e.yoyo) {
|
|
31
|
+
const s = l.value + y.value, i = s * 2, o = r.value % i;
|
|
32
|
+
if (o < l.value) {
|
|
33
|
+
const v = o / l.value * 100;
|
|
34
|
+
a.set(n.value === 1 ? v : 100 - v);
|
|
35
|
+
} else if (o < s)
|
|
36
|
+
a.set(n.value === 1 ? 100 : 0);
|
|
37
|
+
else if (o < s + l.value) {
|
|
38
|
+
const g = 100 - (o - s) / l.value * 100;
|
|
39
|
+
a.set(n.value === 1 ? g : 100 - g);
|
|
114
40
|
} else
|
|
115
|
-
|
|
41
|
+
a.set(n.value === 1 ? 0 : 100);
|
|
116
42
|
} else {
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
43
|
+
const s = l.value + y.value, i = r.value % s;
|
|
44
|
+
if (i < l.value) {
|
|
45
|
+
const o = i / l.value * 100;
|
|
46
|
+
a.set(n.value === 1 ? o : 100 - o);
|
|
121
47
|
} else
|
|
122
|
-
|
|
48
|
+
a.set(n.value === 1 ? 100 : 0);
|
|
123
49
|
}
|
|
124
|
-
}),
|
|
50
|
+
}), B(
|
|
125
51
|
() => e.direction,
|
|
126
52
|
() => {
|
|
127
|
-
|
|
53
|
+
n.value = e.direction === "left" ? 1 : -1, r.value = 0, a.set(0);
|
|
128
54
|
},
|
|
129
55
|
{
|
|
130
56
|
immediate: !0
|
|
131
57
|
}
|
|
132
58
|
);
|
|
133
|
-
const
|
|
134
|
-
e.pauseOnHover && (
|
|
135
|
-
},
|
|
136
|
-
e.pauseOnHover && (
|
|
137
|
-
},
|
|
59
|
+
const T = R(a, (t) => `${150 - t * 2}% center`), x = () => {
|
|
60
|
+
e.pauseOnHover && (f.value = !0);
|
|
61
|
+
}, C = () => {
|
|
62
|
+
e.pauseOnHover && (f.value = !1);
|
|
63
|
+
}, h = p(() => ({
|
|
138
64
|
backgroundImage: `linear-gradient(${e.spread}deg, ${e.color} 0%, ${e.color} 35%, ${e.shineColor} 50%, ${e.color} 65%, ${e.color} 100%)`,
|
|
139
65
|
backgroundSize: "200% auto",
|
|
140
66
|
WebkitBackgroundClip: "text",
|
|
141
67
|
backgroundClip: "text",
|
|
142
68
|
WebkitTextFillColor: "transparent"
|
|
143
69
|
}));
|
|
144
|
-
return (
|
|
70
|
+
return (t, b) => (D(), M(k(w), {
|
|
145
71
|
tag: "span",
|
|
146
|
-
class:
|
|
147
|
-
style:
|
|
148
|
-
onMouseenter:
|
|
149
|
-
onMouseleave:
|
|
72
|
+
class: _(["inline-block", t.className]),
|
|
73
|
+
style: S({ ...h.value, backgroundPosition: k(T) }),
|
|
74
|
+
onMouseenter: x,
|
|
75
|
+
onMouseleave: C
|
|
150
76
|
}, {
|
|
151
|
-
default:
|
|
152
|
-
|
|
77
|
+
default: z(() => [
|
|
78
|
+
H(N(t.text), 1)
|
|
153
79
|
]),
|
|
154
80
|
_: 1
|
|
155
81
|
}, 8, ["class", "style"]));
|
|
156
82
|
}
|
|
157
83
|
});
|
|
158
|
-
|
|
159
|
-
|
|
84
|
+
m.install = (d) => {
|
|
85
|
+
d.component(m.name, m);
|
|
160
86
|
};
|
|
161
87
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
88
|
+
m as GShinyText,
|
|
89
|
+
m as default
|
|
164
90
|
};
|