motion-plus-vue 1.4.0 → 1.5.0-beta.1
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/dist/cjs/index.js +2 -2
- package/dist/components/Carousel/Carousel.d.ts +28 -0
- package/dist/components/Carousel/CarouselView.d.ts +32 -0
- package/dist/components/Carousel/const.d.ts +3 -0
- package/dist/components/Carousel/context.d.ts +15 -0
- package/dist/components/Carousel/index.d.ts +3 -0
- package/dist/components/Carousel/utils/calc-current-page.d.ts +1 -0
- package/dist/components/Carousel/utils/calc-page-insets.d.ts +5 -0
- package/dist/components/Carousel/utils/find-current-index.d.ts +2 -0
- package/dist/components/Carousel/utils/find-next-page.d.ts +3 -0
- package/dist/components/Carousel/utils/find-prev-page.d.ts +3 -0
- package/dist/components/Cursor/Cursor.d.ts +2 -2
- package/dist/components/Ticker/DefaultTickerItem.d.ts +14 -0
- package/dist/components/Ticker/Ticker.d.ts +60 -5
- package/dist/components/Ticker/TickerItem.d.ts +59 -13
- package/dist/components/Ticker/const.d.ts +3 -0
- package/dist/components/Ticker/context.d.ts +4259 -2
- package/dist/components/Ticker/index.d.ts +1 -1
- package/dist/components/Ticker/types.d.ts +16 -1
- package/dist/components/Ticker/utils/layout-strategy.d.ts +2 -0
- package/dist/components/Typewriter/Typewriter.d.ts +1 -1
- package/dist/es/components/Carousel/Carousel.vue.mjs +79 -0
- package/dist/es/components/Carousel/Carousel.vue2.mjs +4 -0
- package/dist/es/components/Carousel/CarouselView.vue.mjs +115 -0
- package/dist/es/components/Carousel/CarouselView.vue2.mjs +4 -0
- package/dist/es/components/Carousel/const.mjs +13 -0
- package/dist/es/components/Carousel/context.mjs +6 -0
- package/dist/es/components/Carousel/utils/calc-current-page.mjs +13 -0
- package/dist/es/components/Carousel/utils/calc-page-insets.mjs +42 -0
- package/dist/es/components/Carousel/utils/find-current-index.mjs +13 -0
- package/dist/es/components/Carousel/utils/find-next-page.mjs +26 -0
- package/dist/es/components/Carousel/utils/find-prev-page.mjs +31 -0
- package/dist/es/components/Ticker/Ticker.vue.mjs +270 -111
- package/dist/es/components/Ticker/TickerItem.vue.mjs +68 -36
- package/dist/es/components/Ticker/const.mjs +12 -3
- package/dist/es/components/Ticker/context.mjs +5 -3
- package/dist/es/components/Ticker/utils/layout-strategy.mjs +57 -0
- package/dist/es/index.mjs +21 -16
- package/dist/es/utils/flatten-slots.mjs +22 -16
- package/dist/index.d.ts +1 -0
- package/package.json +3 -3
- package/dist/es/components/Ticker/use-item-offset.mjs +0 -12
- package/dist/es/components/Ticker/utils/get-cumulative-offset.mjs +0 -9
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useMotionValue as
|
|
3
|
-
import
|
|
4
|
-
import { useFocusNavigation as
|
|
5
|
-
import { alignAlias as
|
|
6
|
-
import { calcNumClones as
|
|
7
|
-
import { calcTotalItemLength as
|
|
8
|
-
import { flattenSlots as
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { defineComponent as je, reactive as Re, computed as s, ref as Ve, useSlots as Fe, watch as ge, createVNode as z, toRef as Ne, createElementBlock as B, openBlock as p, Fragment as $, renderSlot as Ae, unref as c, mergeProps as Xe, withCtx as J, normalizeStyle as Ye, renderList as K, createBlock as Q, resolveDynamicComponent as me, isVNode as Ge } from "vue";
|
|
2
|
+
import { useMotionValue as P, useTransform as ce, wrap as pe, useDomRef as ve, useInView as We, usePageInView as qe, useReducedMotion as He, resize as he, useAnimationFrame as Je, LayoutGroup as Ke, frame as Qe, animate as v, Motion as Ue, motion as Ze, clamp as et } from "motion-v";
|
|
3
|
+
import ye from "./TickerItem.vue.mjs";
|
|
4
|
+
import { useFocusNavigation as tt } from "./use-focus-navigation.mjs";
|
|
5
|
+
import { defaultPageTransition as nt, defaultFadeTransition as at, alignAlias as ot, defaultBounds as Ie } from "./const.mjs";
|
|
6
|
+
import { calcNumClones as it } from "./utils/calc-num-clones.mjs";
|
|
7
|
+
import { calcTotalItemLength as st } from "./utils/calc-total-item-length.mjs";
|
|
8
|
+
import { flattenSlots as rt, renderVNode as xe } from "../../utils/flatten-slots.mjs";
|
|
9
|
+
import { getLayoutStrategy as U } from "./utils/layout-strategy.mjs";
|
|
10
|
+
import { provideTicker as lt } from "./context.mjs";
|
|
11
|
+
import { findNextItemInset as we } from "../Carousel/utils/find-next-page.mjs";
|
|
12
|
+
import { findPrevItemInset as Pe } from "../Carousel/utils/find-prev-page.mjs";
|
|
13
|
+
function Le(I) {
|
|
14
|
+
return typeof I == "function" || Object.prototype.toString.call(I) === "[object Object]" && !Ge(I);
|
|
12
15
|
}
|
|
13
|
-
const
|
|
16
|
+
const Pt = /* @__PURE__ */ je({
|
|
14
17
|
__name: "Ticker",
|
|
15
18
|
props: {
|
|
16
19
|
axis: {
|
|
17
20
|
default: "x"
|
|
18
21
|
},
|
|
19
|
-
style: {},
|
|
20
22
|
velocity: {
|
|
21
23
|
default: 50
|
|
22
24
|
},
|
|
@@ -36,148 +38,305 @@ const Ne = /* @__PURE__ */ le({
|
|
|
36
38
|
overflow: {
|
|
37
39
|
type: Boolean,
|
|
38
40
|
default: !1
|
|
41
|
+
},
|
|
42
|
+
loop: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: !0
|
|
45
|
+
},
|
|
46
|
+
safeMargin: {
|
|
47
|
+
default: 0
|
|
48
|
+
},
|
|
49
|
+
fade: {
|
|
50
|
+
default: 0
|
|
51
|
+
},
|
|
52
|
+
fadeTransition: {
|
|
53
|
+
default: () => at
|
|
54
|
+
},
|
|
55
|
+
pageTransition: {
|
|
56
|
+
default: () => nt
|
|
57
|
+
},
|
|
58
|
+
_dragX: {
|
|
59
|
+
type: [Object, Boolean]
|
|
60
|
+
},
|
|
61
|
+
_dragY: {
|
|
62
|
+
type: [Object, Boolean]
|
|
63
|
+
},
|
|
64
|
+
snap: {
|
|
65
|
+
type: [String, Boolean]
|
|
66
|
+
},
|
|
67
|
+
as: {
|
|
68
|
+
default: "div"
|
|
69
|
+
},
|
|
70
|
+
style: {},
|
|
71
|
+
onDragEnd: {},
|
|
72
|
+
drag: {
|
|
73
|
+
type: [Boolean, String]
|
|
74
|
+
},
|
|
75
|
+
dragConstraints: {
|
|
76
|
+
type: [Boolean, Object]
|
|
77
|
+
},
|
|
78
|
+
dragMomentum: {
|
|
79
|
+
type: Boolean
|
|
39
80
|
}
|
|
40
81
|
},
|
|
41
|
-
setup(
|
|
42
|
-
const e =
|
|
82
|
+
setup(I) {
|
|
83
|
+
const e = I, t = Re({
|
|
84
|
+
direction: "ltr",
|
|
43
85
|
visibleLength: 0,
|
|
44
86
|
inset: 0,
|
|
45
87
|
totalItemLength: 0,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}),
|
|
88
|
+
containerLength: 0,
|
|
89
|
+
itemPositions: [],
|
|
90
|
+
isMeasured: !1,
|
|
91
|
+
maxInset: null
|
|
92
|
+
}), D = s(() => ot[e.align] || e.align), h = s(() => U(e.axis, t.direction).sign), Z = Ve(!1), E = P(1), ee = P(0), d = s(() => e.offset ?? ee), be = ce(() => t.direction === "rtl" ? pe(t.totalItemLength + e.gap + t.inset, t.inset, d.value.get()) : pe(-t.totalItemLength - e.gap - t.inset, -t.inset, d.value.get())), te = P(0), y = s(() => Z.value ? te : e.loop ? be : d.value), g = ve(), _ = ve(), Se = We(g, {
|
|
51
93
|
margin: "100px"
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
94
|
+
}), Me = qe(), L = s(() => Se.value && Me.value), ke = He(), j = Fe(), x = s(() => {
|
|
95
|
+
var n;
|
|
96
|
+
return rt((n = j.default) == null ? void 0 : n.call(j));
|
|
97
|
+
});
|
|
98
|
+
function R() {
|
|
99
|
+
if (!g.value || !_.value) return;
|
|
100
|
+
const n = window.getComputedStyle(g.value).direction, {
|
|
101
|
+
measureItem: i,
|
|
102
|
+
lengthProp: a,
|
|
103
|
+
viewportLengthProp: o,
|
|
104
|
+
getCumulativeInset: u
|
|
105
|
+
} = U(e.axis, n), {
|
|
106
|
+
safeMargin: l,
|
|
107
|
+
overflow: f,
|
|
108
|
+
loop: w
|
|
109
|
+
} = e, k = r.value === "x" ? "paddingLeft" : "paddingTop", A = r.value === "x" ? "paddingRight" : "paddingBottom", X = g.value, C = _.value.querySelectorAll(".ticker-item");
|
|
110
|
+
if (!C.length) return;
|
|
111
|
+
let le = !1;
|
|
112
|
+
const O = [];
|
|
113
|
+
for (let T = 0; T < C.length; T++) {
|
|
114
|
+
const q = i(C[T], X);
|
|
115
|
+
O.push(q);
|
|
116
|
+
const H = t.itemPositions[T];
|
|
117
|
+
(!H || q.start !== H.start || q.end !== H.end) && (le = !0);
|
|
65
118
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
119
|
+
const Y = Math.min(X[a], window[o]);
|
|
120
|
+
let G = e.overflow ? window[o] : Y;
|
|
121
|
+
l > 0 && (G += l * 2);
|
|
122
|
+
const W = st(O), ue = window.getComputedStyle(X), fe = parseInt(ue[k] ?? 0), Ee = parseInt(ue[A] ?? 0), de = f ? u(C[0]) : fe, _e = w === !1 ? Math.max(0, W - Y + fe + Ee) : null;
|
|
123
|
+
(G !== t.visibleLength || W !== t.totalItemLength || de !== t.inset || t.itemPositions.length !== O.length || le) && (t.direction = n, t.visibleLength = G, t.itemPositions = O, t.totalItemLength = W, t.inset = de, t.containerLength = Y, t.maxInset = _e, t.isMeasured = !0);
|
|
68
124
|
}
|
|
69
|
-
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
125
|
+
ge([x, L, () => e.overflow], (n, i, a) => {
|
|
126
|
+
if (!L.value || !g.value) return;
|
|
127
|
+
R();
|
|
128
|
+
const o = e.overflow ? he(R) : void 0, u = he(g.value, R);
|
|
129
|
+
a(() => {
|
|
130
|
+
o == null || o(), u();
|
|
75
131
|
});
|
|
76
132
|
}, {
|
|
77
133
|
immediate: !0,
|
|
78
134
|
flush: "post"
|
|
79
135
|
});
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
|
|
136
|
+
const b = s(() => t.totalItemLength > 0);
|
|
137
|
+
Je((n, i) => {
|
|
138
|
+
if (b.value && L.value && d.value === ee && !ke.value) {
|
|
139
|
+
const a = i / 1e3 * (e.velocity * h.value * E.get());
|
|
140
|
+
d.value.set(d.value.get() - a);
|
|
85
141
|
}
|
|
86
142
|
});
|
|
87
|
-
const
|
|
143
|
+
const ne = s(() => !b.value || !t.visibleLength ? 0 : it(t.visibleLength, t.itemPositions, e.gap)), ae = s(() => t.totalItemLength === 0 ? 0 : (t.totalItemLength + e.gap) * (ne.value + 1)), Ce = s(() => {
|
|
144
|
+
if (!e.loop) return [];
|
|
88
145
|
const n = [];
|
|
89
|
-
for (let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
146
|
+
for (let i = 0; i < ne.value; i++) {
|
|
147
|
+
const a = [];
|
|
148
|
+
x.value.forEach((u, l) => {
|
|
149
|
+
let f;
|
|
150
|
+
const w = t.itemPositions[l], k = (t.totalItemLength + e.gap) * (i + 1), A = w ? {
|
|
151
|
+
start: w.start + k,
|
|
152
|
+
end: w.end + k
|
|
153
|
+
} : Ie;
|
|
154
|
+
a.push(z(ye, {
|
|
155
|
+
key: `clone-${i}-${l}`,
|
|
156
|
+
offset: y.value,
|
|
99
157
|
axis: e.axis,
|
|
100
|
-
listSize:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
alignItems:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
158
|
+
listSize: ae.value,
|
|
159
|
+
itemIndex: l,
|
|
160
|
+
cloneIndex: l,
|
|
161
|
+
bounds: A,
|
|
162
|
+
alignItems: D.value,
|
|
163
|
+
size: e.itemSize,
|
|
164
|
+
safeMargin: e.safeMargin,
|
|
165
|
+
numItems: x.value.length
|
|
166
|
+
}, Le(f = xe([u])) ? f : {
|
|
167
|
+
default: () => [f]
|
|
108
168
|
}));
|
|
109
169
|
});
|
|
170
|
+
const o = `ticker-group-${i}`;
|
|
171
|
+
n.push(z(Ke, {
|
|
172
|
+
key: o,
|
|
173
|
+
id: o
|
|
174
|
+
}, Le(a) ? a : {
|
|
175
|
+
default: () => [a]
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
110
178
|
return n;
|
|
111
|
-
}),
|
|
112
|
-
|
|
113
|
-
|
|
179
|
+
}), r = Ne(e, "axis");
|
|
180
|
+
tt(g, r, te, d, (n) => {
|
|
181
|
+
Z.value = n;
|
|
114
182
|
});
|
|
115
|
-
const
|
|
183
|
+
const Oe = {
|
|
116
184
|
display: "flex",
|
|
117
185
|
position: "relative"
|
|
118
|
-
},
|
|
186
|
+
}, Te = {
|
|
119
187
|
display: "flex",
|
|
120
188
|
position: "relative",
|
|
121
|
-
willChange:
|
|
189
|
+
willChange: "transform",
|
|
122
190
|
listStyleType: "none",
|
|
123
191
|
padding: 0,
|
|
124
192
|
margin: 0,
|
|
125
|
-
justifyContent: "flex-start"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
193
|
+
justifyContent: "flex-start"
|
|
194
|
+
};
|
|
195
|
+
function oe(n) {
|
|
196
|
+
return t.maxInset !== null ? et(-t.maxInset, 0, n) : n;
|
|
197
|
+
}
|
|
198
|
+
lt({
|
|
199
|
+
state: t,
|
|
200
|
+
gap: s(() => e.gap),
|
|
201
|
+
clampOffset: oe,
|
|
202
|
+
renderedOffset: y
|
|
203
|
+
});
|
|
204
|
+
const S = s(() => e.axis === "x" ? e == null ? void 0 : e._dragX : e == null ? void 0 : e._dragY);
|
|
205
|
+
let M = null;
|
|
206
|
+
const V = s(() => t.maxInset !== null ? r.value === "x" ? h.value > 0 ? {
|
|
207
|
+
left: t.maxInset * -1,
|
|
208
|
+
right: 0
|
|
209
|
+
} : {
|
|
210
|
+
right: t.maxInset,
|
|
211
|
+
left: 0
|
|
212
|
+
} : {
|
|
213
|
+
top: t.maxInset * -1,
|
|
214
|
+
bottom: 0
|
|
215
|
+
} : {});
|
|
216
|
+
function ie() {
|
|
217
|
+
M && (M.stop(), M = null);
|
|
218
|
+
}
|
|
219
|
+
const ze = s(() => !e.onDragEnd && e.drag && S ? () => {
|
|
220
|
+
S.value.jump(d.value.get()), ie();
|
|
221
|
+
} : e.onPointerDown), Be = s(() => !e.onDragEnd && e.drag && S ? (n, {
|
|
222
|
+
velocity: i
|
|
223
|
+
}) => {
|
|
224
|
+
const a = d.value.get();
|
|
225
|
+
ie(), Qe.postRender(() => {
|
|
226
|
+
let o = a + i[r.value] * (e.snap ? 0.3 : 0.8);
|
|
227
|
+
if (e.snap)
|
|
228
|
+
if (i[r.value] < 0)
|
|
229
|
+
o = -we(-a, t.itemPositions, e.gap, -o);
|
|
230
|
+
else if (i[r.value] > 0)
|
|
231
|
+
o = -Pe(-a, t.itemPositions, e.gap, -o, t.containerLength);
|
|
232
|
+
else {
|
|
233
|
+
const l = -we(-a, t.itemPositions, e.gap, -a), f = -Pe(-a, t.itemPositions, e.gap, -a, t.containerLength);
|
|
234
|
+
o = Math.abs(a - l) < Math.abs(a - f) ? l : f;
|
|
235
|
+
}
|
|
236
|
+
const u = e.loop ? {} : h.value > 0 ? {
|
|
237
|
+
max: 0,
|
|
238
|
+
min: V.value[r.value === "x" ? "left" : "top"]
|
|
239
|
+
} : {
|
|
240
|
+
min: 0,
|
|
241
|
+
max: V.value.right
|
|
242
|
+
};
|
|
243
|
+
M = v(S, oe(o * h.value) * h.value, e.snap ? e.pageTransition : {
|
|
244
|
+
type: "inertia",
|
|
245
|
+
velocity: i[r.value],
|
|
246
|
+
modifyTarget: () => o,
|
|
247
|
+
bounceDamping: 40,
|
|
248
|
+
bounceStiffness: 400,
|
|
249
|
+
...u
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
} : e.onDragEnd), F = P(e.loop ? 0 : 1), N = P(0), $e = s(() => U(r.value, t.direction)), se = s(() => typeof e.fade == "number" ? "px" : ""), re = ce(() => `linear-gradient(to ${$e.value.direction}, rgba(0,0,0,${F.get()}) 0px, black ${e.fade}${se.value}, black calc(100% - ${e.fade}${se.value}), rgba(0,0,0,${N.get()}) 100%)`), De = s(() => e.fade ? {
|
|
253
|
+
maskImage: re,
|
|
254
|
+
WebkitMaskImage: re
|
|
255
|
+
} : {}), m = {
|
|
256
|
+
start: !0,
|
|
257
|
+
end: !1
|
|
258
|
+
};
|
|
259
|
+
return ge(y, (n, i, a) => {
|
|
260
|
+
const o = (l) => {
|
|
261
|
+
if (t.maxInset === null) return;
|
|
262
|
+
const f = t.maxInset * -1;
|
|
263
|
+
l *= h.value, l < 0 ? m.start && (v(F, 0, e.fadeTransition), m.start = !1) : m.start || (v(F, 1, e.fadeTransition), m.start = !0), l > f ? m.end && (v(N, 0, e.fadeTransition), m.end = !1) : m.end || (v(N, 1, e.fadeTransition), m.end = !0);
|
|
264
|
+
};
|
|
265
|
+
let u = () => {
|
|
266
|
+
};
|
|
267
|
+
n && (u = n.on("change", o)), a(u);
|
|
268
|
+
}, {
|
|
269
|
+
immediate: !0
|
|
270
|
+
}), (n, i) => (p(), B($, null, [z(c(Ue), Xe(n.$attrs, {
|
|
138
271
|
ref_key: "containerRef",
|
|
139
|
-
ref:
|
|
272
|
+
ref: g,
|
|
273
|
+
as: n.as,
|
|
140
274
|
style: {
|
|
141
|
-
|
|
275
|
+
overflowX: !n.overflow && r.value === "x" ? "clip" : void 0,
|
|
276
|
+
overflowY: !n.overflow && r.value === "y" ? "clip" : void 0,
|
|
277
|
+
...Oe,
|
|
142
278
|
...e.style,
|
|
143
|
-
|
|
279
|
+
...De.value
|
|
144
280
|
},
|
|
145
|
-
|
|
146
|
-
|
|
281
|
+
drag: n.drag,
|
|
282
|
+
_dragX: n._dragX,
|
|
283
|
+
_dragY: n._dragY,
|
|
284
|
+
"drag-constraints": V.value,
|
|
285
|
+
"drag-momentum": n.dragMomentum,
|
|
286
|
+
onPointerenter: i[0] || (i[0] = () => {
|
|
287
|
+
c(v)(c(E), n.hoverFactor);
|
|
288
|
+
}),
|
|
289
|
+
onPointerleave: i[1] || (i[1] = () => {
|
|
290
|
+
c(v)(c(E), 1);
|
|
147
291
|
}),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
})
|
|
292
|
+
onPointerdown: ze.value,
|
|
293
|
+
onDragEnd: Be.value
|
|
151
294
|
}), {
|
|
152
|
-
default:
|
|
295
|
+
default: J(() => [z(c(Ze).ul, {
|
|
153
296
|
ref_key: "listRef",
|
|
154
|
-
ref:
|
|
155
|
-
|
|
297
|
+
ref: _,
|
|
298
|
+
role: "group",
|
|
299
|
+
style: Ye({
|
|
300
|
+
...Te,
|
|
301
|
+
flexDirection: r.value === "x" ? "row" : "column",
|
|
302
|
+
gap: `${n.gap}px`,
|
|
303
|
+
x: r.value === "x" ? y.value : 0,
|
|
304
|
+
y: r.value === "y" ? y.value : 0,
|
|
305
|
+
opacity: b.value ? 1 : 0,
|
|
306
|
+
alignItems: D.value,
|
|
307
|
+
willChange: b.value && L.value ? "transform" : void 0,
|
|
308
|
+
width: "100%",
|
|
309
|
+
height: "100%",
|
|
310
|
+
maxHeight: "100%",
|
|
311
|
+
maxWidth: "100%"
|
|
312
|
+
})
|
|
156
313
|
}, {
|
|
157
|
-
default:
|
|
158
|
-
key: `original-${
|
|
159
|
-
axis:
|
|
160
|
-
offset:
|
|
161
|
-
"list-size":
|
|
162
|
-
"item-index":
|
|
163
|
-
bounds: t.itemPositions[
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
314
|
+
default: J(() => [(p(!0), B($, null, K(x.value, (a, o) => (p(), Q(ye, {
|
|
315
|
+
key: `original-${o}`,
|
|
316
|
+
axis: r.value,
|
|
317
|
+
offset: y.value,
|
|
318
|
+
"list-size": ae.value,
|
|
319
|
+
"item-index": o,
|
|
320
|
+
bounds: t.itemPositions[o] ?? c(Ie),
|
|
321
|
+
"align-items": D.value,
|
|
322
|
+
size: n.itemSize,
|
|
323
|
+
reproject: n.loop,
|
|
324
|
+
"safe-margin": n.safeMargin,
|
|
325
|
+
"num-items": x.value.length
|
|
167
326
|
}, {
|
|
168
|
-
default:
|
|
169
|
-
key:
|
|
327
|
+
default: J(() => [(p(!0), B($, null, K(c(xe)([a]), (u, l) => (p(), Q(me(u), {
|
|
328
|
+
key: l
|
|
170
329
|
}))), 128))]),
|
|
171
330
|
_: 2
|
|
172
|
-
}, 1032, ["axis", "offset", "list-size", "item-index", "bounds", "
|
|
173
|
-
key:
|
|
331
|
+
}, 1032, ["axis", "offset", "list-size", "item-index", "bounds", "align-items", "size", "reproject", "safe-margin", "num-items"]))), 128)), (p(!0), B($, null, K(Ce.value, (a) => (p(), Q(me(a), {
|
|
332
|
+
key: a.key
|
|
174
333
|
}))), 128))]),
|
|
175
334
|
_: 1
|
|
176
335
|
}, 8, ["style"])]),
|
|
177
336
|
_: 1
|
|
178
|
-
}, 16, ["style"]));
|
|
337
|
+
}, 16, ["as", "style", "drag", "_dragX", "_dragY", "drag-constraints", "drag-momentum", "onPointerdown", "onDragEnd"]), Ae(n.$slots, "after")], 64));
|
|
179
338
|
}
|
|
180
339
|
});
|
|
181
340
|
export {
|
|
182
|
-
|
|
341
|
+
Pt as default
|
|
183
342
|
};
|
|
@@ -1,52 +1,84 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useTransform as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { defineComponent as z, computed as l, toRefs as b, renderSlot as c, createBlock as S, openBlock as T, unref as B, normalizeProps as w, mergeProps as P, withCtx as _ } from "vue";
|
|
2
|
+
import { useTransform as m, motion as j } from "motion-v";
|
|
3
|
+
import { useTicker as C, provideTickerItem as O } from "./context.mjs";
|
|
4
|
+
import { getLayoutStrategy as L } from "./utils/layout-strategy.mjs";
|
|
5
|
+
const F = /* @__PURE__ */ z({
|
|
5
6
|
__name: "TickerItem",
|
|
6
7
|
props: {
|
|
7
8
|
offset: {},
|
|
8
9
|
axis: {},
|
|
9
|
-
listSize: {},
|
|
10
|
-
inset: {},
|
|
10
|
+
listSize: { default: 0 },
|
|
11
11
|
bounds: {},
|
|
12
|
+
numItems: { default: 0 },
|
|
12
13
|
itemIndex: {},
|
|
13
14
|
cloneIndex: {},
|
|
14
15
|
alignItems: {},
|
|
15
|
-
|
|
16
|
+
size: { default: "auto" },
|
|
17
|
+
safeMargin: {},
|
|
18
|
+
reproject: { type: Boolean, default: !0 }
|
|
16
19
|
},
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"aria-hidden": m.value ? !0 : void 0,
|
|
32
|
-
style: {
|
|
33
|
-
flexGrow: 0,
|
|
34
|
-
flexShrink: 0,
|
|
35
|
-
flexBasis: e.itemSize === "fill" ? "100%" : void 0,
|
|
36
|
-
display: e.itemSize === "fill" ? "flex" : void 0,
|
|
37
|
-
height: e.axis === "x" ? r.value : void 0,
|
|
38
|
-
width: e.axis === "y" ? r.value : void 0,
|
|
39
|
-
x: e.axis === "x" ? n(o) : 0,
|
|
40
|
-
y: e.axis === "y" ? n(o) : 0
|
|
20
|
+
setup(p) {
|
|
21
|
+
const e = p, { state: o } = C(), s = l(() => L(e.axis, o.direction).sign), n = m(() => {
|
|
22
|
+
if (!e.reproject)
|
|
23
|
+
return 0;
|
|
24
|
+
const { offset: t, bounds: i, listSize: r, safeMargin: a } = e, { start: y, end: d } = i;
|
|
25
|
+
if (!y && !d || !r)
|
|
26
|
+
return 0;
|
|
27
|
+
const f = t.get();
|
|
28
|
+
if (f * s.value + d <= -o.inset - a)
|
|
29
|
+
return r * s.value;
|
|
30
|
+
if (a > 0) {
|
|
31
|
+
const k = o.visibleLength - a - o.inset;
|
|
32
|
+
if (f * s.value + i.start >= k)
|
|
33
|
+
return -r * s.value;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
return 0;
|
|
36
|
+
}), v = m(() => {
|
|
37
|
+
const t = e.offset.get(), i = n.get();
|
|
38
|
+
return !e.bounds.start && !e.bounds.end || !e.listSize ? 0 : t * s.value + e.bounds.start + i * s.value;
|
|
39
|
+
}), x = l(() => e.cloneIndex === void 0 ? {
|
|
40
|
+
"aria-hidden": !1,
|
|
41
|
+
"aria-posinset": e.itemIndex + 1,
|
|
42
|
+
"aria-setsize": e.numItems
|
|
43
|
+
} : {
|
|
44
|
+
"aria-hidden": !0
|
|
45
|
+
}), u = l(() => {
|
|
46
|
+
const t = e.size === "fill", i = e.alignItems === "stretch" ? "100%" : "fit-content";
|
|
47
|
+
return {
|
|
48
|
+
class: e.cloneIndex === void 0 ? "ticker-item" : "clone-item",
|
|
49
|
+
style: {
|
|
50
|
+
flexGrow: 0,
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
position: "relative",
|
|
53
|
+
flexBasis: t ? "100%" : void 0,
|
|
54
|
+
display: t ? "grid" : void 0,
|
|
55
|
+
gridTemplateColumns: t ? "1fr" : void 0,
|
|
56
|
+
gridTemplateRows: t ? "1fr" : void 0,
|
|
57
|
+
minWidth: t ? 0 : void 0,
|
|
58
|
+
minHeight: t ? 0 : void 0,
|
|
59
|
+
height: e.axis === "x" ? i : void 0,
|
|
60
|
+
width: e.axis === "y" ? i : void 0,
|
|
61
|
+
x: e.axis === "x" ? n : 0,
|
|
62
|
+
y: e.axis === "y" ? n : 0
|
|
63
|
+
},
|
|
64
|
+
...x.value
|
|
65
|
+
};
|
|
66
|
+
}), { bounds: g, itemIndex: I, cloneIndex: h } = b(e);
|
|
67
|
+
return O({
|
|
68
|
+
offset: v,
|
|
69
|
+
bounds: g,
|
|
70
|
+
projection: n,
|
|
71
|
+
itemIndex: I,
|
|
72
|
+
cloneIndex: h,
|
|
73
|
+
props: u
|
|
74
|
+
}), (t, i) => t.size === "manual" ? c(t.$slots, "default", { key: 0 }) : (T(), S(B(j).li, w(P({ key: 1 }, u.value)), {
|
|
75
|
+
default: _(() => [
|
|
76
|
+
c(t.$slots, "default")
|
|
45
77
|
]),
|
|
46
78
|
_: 3
|
|
47
|
-
}, 16
|
|
79
|
+
}, 16));
|
|
48
80
|
}
|
|
49
81
|
});
|
|
50
82
|
export {
|
|
51
|
-
|
|
83
|
+
F as default
|
|
52
84
|
};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
const t = { start: 0, end: 0 },
|
|
1
|
+
const t = { start: 0, end: 0 }, n = {
|
|
2
2
|
start: "flex-start",
|
|
3
3
|
end: "flex-end"
|
|
4
|
+
}, a = {
|
|
5
|
+
duration: 0.2,
|
|
6
|
+
ease: "linear"
|
|
7
|
+
}, e = {
|
|
8
|
+
type: "spring",
|
|
9
|
+
stiffness: 400,
|
|
10
|
+
damping: 40
|
|
4
11
|
};
|
|
5
12
|
export {
|
|
6
|
-
|
|
7
|
-
t as defaultBounds
|
|
13
|
+
n as alignAlias,
|
|
14
|
+
t as defaultBounds,
|
|
15
|
+
a as defaultFadeTransition,
|
|
16
|
+
e as defaultPageTransition
|
|
8
17
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createContext as e } from "motion-v";
|
|
2
|
-
const [
|
|
2
|
+
const [t, o] = e("TickerItemContext"), [c, i] = e("TickerInfo");
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
o as
|
|
4
|
+
i as provideTicker,
|
|
5
|
+
o as provideTickerItem,
|
|
6
|
+
c as useTicker,
|
|
7
|
+
t as useTickerItem
|
|
6
8
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function d(t, e, f, r, a) {
|
|
2
|
+
return {
|
|
3
|
+
sign: 1,
|
|
4
|
+
direction: a,
|
|
5
|
+
lengthProp: e,
|
|
6
|
+
viewportLengthProp: f,
|
|
7
|
+
paddingStartProp: r,
|
|
8
|
+
measureItem: (n) => ({
|
|
9
|
+
start: n[t],
|
|
10
|
+
end: n[t] + n[e]
|
|
11
|
+
}),
|
|
12
|
+
getCumulativeInset: (n) => {
|
|
13
|
+
let s = 0, o = n;
|
|
14
|
+
for (; o; )
|
|
15
|
+
s += o[t], o = o.offsetParent;
|
|
16
|
+
return s;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const g = d(
|
|
21
|
+
"offsetLeft",
|
|
22
|
+
"offsetWidth",
|
|
23
|
+
"innerWidth",
|
|
24
|
+
"paddingLeft",
|
|
25
|
+
"right"
|
|
26
|
+
), u = d(
|
|
27
|
+
"offsetTop",
|
|
28
|
+
"offsetHeight",
|
|
29
|
+
"innerHeight",
|
|
30
|
+
"paddingTop",
|
|
31
|
+
"bottom"
|
|
32
|
+
);
|
|
33
|
+
function i(t, e) {
|
|
34
|
+
return ((e == null ? void 0 : e.offsetWidth) ?? window.innerWidth) - (t.offsetLeft + t.offsetWidth);
|
|
35
|
+
}
|
|
36
|
+
const h = {
|
|
37
|
+
...g,
|
|
38
|
+
sign: -1,
|
|
39
|
+
direction: "left",
|
|
40
|
+
paddingStartProp: "paddingRight",
|
|
41
|
+
measureItem: (t, e) => {
|
|
42
|
+
const f = t.offsetWidth, r = i(t, e);
|
|
43
|
+
return { start: r, end: r + f };
|
|
44
|
+
},
|
|
45
|
+
getCumulativeInset: (t) => {
|
|
46
|
+
let e = 0, f = t;
|
|
47
|
+
for (; f; )
|
|
48
|
+
e += i(f, f.offsetParent), f = f.offsetParent;
|
|
49
|
+
return e;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function l(t, e) {
|
|
53
|
+
return t === "y" ? u : e === "ltr" ? g : h;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
l as getLayoutStrategy
|
|
57
|
+
};
|