motion-plus-vue 1.3.1 → 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.
Files changed (49) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/components/Carousel/Carousel.d.ts +28 -0
  3. package/dist/components/Carousel/CarouselView.d.ts +32 -0
  4. package/dist/components/Carousel/const.d.ts +3 -0
  5. package/dist/components/Carousel/context.d.ts +15 -0
  6. package/dist/components/Carousel/index.d.ts +3 -0
  7. package/dist/components/Carousel/utils/calc-current-page.d.ts +1 -0
  8. package/dist/components/Carousel/utils/calc-page-insets.d.ts +5 -0
  9. package/dist/components/Carousel/utils/find-current-index.d.ts +2 -0
  10. package/dist/components/Carousel/utils/find-next-page.d.ts +3 -0
  11. package/dist/components/Carousel/utils/find-prev-page.d.ts +3 -0
  12. package/dist/components/Cursor/Cursor.d.ts +2 -2
  13. package/dist/components/Ticker/DefaultTickerItem.d.ts +14 -0
  14. package/dist/components/Ticker/Ticker.d.ts +60 -5
  15. package/dist/components/Ticker/TickerItem.d.ts +59 -13
  16. package/dist/components/Ticker/const.d.ts +3 -0
  17. package/dist/components/Ticker/context.d.ts +4259 -2
  18. package/dist/components/Ticker/index.d.ts +1 -1
  19. package/dist/components/Ticker/types.d.ts +16 -1
  20. package/dist/components/Ticker/utils/layout-strategy.d.ts +2 -0
  21. package/dist/components/Typewriter/Typewriter.d.ts +98 -0
  22. package/dist/components/Typewriter/index.d.ts +1 -0
  23. package/dist/components/Typewriter/types.d.ts +6 -0
  24. package/dist/es/components/Carousel/Carousel.vue.mjs +79 -0
  25. package/dist/es/components/Carousel/Carousel.vue2.mjs +4 -0
  26. package/dist/es/components/Carousel/CarouselView.vue.mjs +115 -0
  27. package/dist/es/components/Carousel/CarouselView.vue2.mjs +4 -0
  28. package/dist/es/components/Carousel/const.mjs +13 -0
  29. package/dist/es/components/Carousel/context.mjs +6 -0
  30. package/dist/es/components/Carousel/utils/calc-current-page.mjs +13 -0
  31. package/dist/es/components/Carousel/utils/calc-page-insets.mjs +42 -0
  32. package/dist/es/components/Carousel/utils/find-current-index.mjs +13 -0
  33. package/dist/es/components/Carousel/utils/find-next-page.mjs +26 -0
  34. package/dist/es/components/Carousel/utils/find-prev-page.mjs +31 -0
  35. package/dist/es/components/Ticker/Ticker.vue.mjs +270 -111
  36. package/dist/es/components/Ticker/TickerItem.vue.mjs +68 -36
  37. package/dist/es/components/Ticker/const.mjs +12 -3
  38. package/dist/es/components/Ticker/context.mjs +5 -3
  39. package/dist/es/components/Ticker/utils/layout-strategy.mjs +57 -0
  40. package/dist/es/components/Typewriter/Typewriter.vue.mjs +129 -0
  41. package/dist/es/components/Typewriter/Typewriter.vue2.mjs +4 -0
  42. package/dist/es/components/Typewriter/types.mjs +8 -0
  43. package/dist/es/index.mjs +23 -16
  44. package/dist/es/utils/flatten-slots.mjs +22 -16
  45. package/dist/index.d.ts +2 -0
  46. package/dist/utils/types.d.ts +0 -0
  47. package/package.json +5 -2
  48. package/dist/es/components/Ticker/use-item-offset.mjs +0 -12
  49. package/dist/es/components/Ticker/utils/get-cumulative-offset.mjs +0 -9
@@ -1,22 +1,24 @@
1
- import { defineComponent as le, reactive as re, computed as l, useSlots as ue, ref as fe, watch as ce, createVNode as W, toRef as me, createBlock as I, openBlock as m, unref as u, mergeProps as de, withCtx as _, normalizeStyle as ve, createElementBlock as O, Fragment as R, renderList as V, resolveDynamicComponent as E, isVNode as ge } from "vue";
2
- import { useMotionValue as B, useTransform as pe, wrap as he, useDomRef as q, useInView as ye, usePageInView as xe, useReducedMotion as we, resize as G, useAnimationFrame as Ie, motion as J, animate as K } from "motion-v";
3
- import Q from "./TickerItem.vue.mjs";
4
- import { useFocusNavigation as Le } from "./use-focus-navigation.mjs";
5
- import { alignAlias as Se, defaultBounds as U } from "./const.mjs";
6
- import { calcNumClones as Pe } from "./utils/calc-num-clones.mjs";
7
- import { calcTotalItemLength as be } from "./utils/calc-total-item-length.mjs";
8
- import { flattenSlots as ze, renderVNode as X } from "../../utils/flatten-slots.mjs";
9
- import { getCumulativeOffset as ke } from "./utils/get-cumulative-offset.mjs";
10
- function Ce(v) {
11
- return typeof v == "function" || Object.prototype.toString.call(v) === "[object Object]" && !ge(v);
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 Ne = /* @__PURE__ */ le({
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(v) {
42
- const e = v, t = re({
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
- itemPositions: []
47
- }), L = l(() => Se[e.align] || e.align), S = ue(), P = l(() => {
48
- var n;
49
- return ze((n = S.default) == null ? void 0 : n.call(S));
50
- }), F = fe(!1), b = B(1), M = B(0), g = l(() => e.offset ?? M), Y = pe(() => he(-t.totalItemLength - e.gap - t.inset, -t.inset, g.value.get())), T = B(0), h = l(() => F.value ? T : Y), f = q(), z = q(), Z = ye(f, {
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
- }), ee = xe(), y = l(() => Z.value && ee.value), te = we();
53
- function k() {
54
- if (!f.value || !z.value) return;
55
- const n = e.axis === "x" ? "innerWidth" : "innerHeight", o = e.axis === "x" ? "offsetWidth" : "offsetHeight", i = e.axis === "x" ? "offsetLeft" : "offsetTop", s = e.axis === "x" ? "paddingLeft" : "paddingTop", a = f.value, c = z.value.querySelectorAll(".ticker-item");
56
- if (!c.length) return;
57
- let w = !1;
58
- const p = [];
59
- for (let r = 0; r < c.length; r++) {
60
- const C = c[r];
61
- p.push({
62
- start: C[i],
63
- end: C[i] + C[o]
64
- }), (!t.itemPositions[r] || p[r].start !== t.itemPositions[r].start || p[r].end !== t.itemPositions[r].end) && (w = !0);
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 A = e.overflow ? window[n] : Math.min(a[o], window[n]), D = be(p), se = window.getComputedStyle(a), ae = parseInt(se[s] ?? "0"), H = e.overflow ? ke(c[0], e.axis) : ae;
67
- (A !== t.visibleLength || D !== t.totalItemLength || H !== t.inset || w) && (t.visibleLength = A, t.itemPositions = p, t.totalItemLength = D, t.inset = H);
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
- ce([P, y], (n, o, i) => {
70
- if (!y.value || !f.value) return;
71
- k();
72
- const s = e.overflow ? G(k) : void 0, a = G(f.value, k);
73
- i(() => {
74
- s == null || s(), a();
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 x = l(() => t.totalItemLength > 0);
81
- Ie((n, o) => {
82
- if (x.value && y.value && g.value === M && !te.value) {
83
- const i = o / 1e3 * (e.velocity * b.get());
84
- g.value.set(g.value.get() - i);
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 $ = l(() => !x.value || !t.visibleLength ? 0 : Pe(t.visibleLength, t.itemPositions, e.gap)), N = l(() => t.totalItemLength === 0 ? 0 : (t.totalItemLength + e.gap) * ($.value + 1)), ne = l(() => {
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 o = 0; o < $.value; o++)
90
- P.value.forEach((i, s) => {
91
- let a;
92
- const d = t.itemPositions[s], c = (t.totalItemLength + e.gap) * (o + 1), w = d ? {
93
- start: d.start + c,
94
- end: d.end + c
95
- } : U;
96
- n.push(W(Q, {
97
- key: `clone-${o}-${s}`,
98
- offset: h.value,
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: N.value,
101
- cloneIndex: s,
102
- bounds: w,
103
- inset: t.inset,
104
- alignItems: L.value,
105
- itemSize: e.itemSize
106
- }, Ce(a = X([i])) ? a : {
107
- default: () => [a]
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
- }), j = me(e, "axis");
112
- Le(f, j, T, g, (n) => {
113
- F.value = n;
179
+ }), r = Ne(e, "axis");
180
+ tt(g, r, te, d, (n) => {
181
+ Z.value = n;
114
182
  });
115
- const oe = {
183
+ const Oe = {
116
184
  display: "flex",
117
185
  position: "relative"
118
- }, ie = l(() => ({
186
+ }, Te = {
119
187
  display: "flex",
120
188
  position: "relative",
121
- willChange: x.value && y.value ? "transform" : void 0,
189
+ willChange: "transform",
122
190
  listStyleType: "none",
123
191
  padding: 0,
124
192
  margin: 0,
125
- justifyContent: "flex-start",
126
- flexDirection: e.axis === "x" ? "row" : "column",
127
- gap: `${e.gap}px`,
128
- alignItems: L.value,
129
- x: e.axis === "x" ? h.value : 0,
130
- y: e.axis === "y" ? h.value : 0,
131
- opacity: x.value ? 1 : 0,
132
- width: "100%",
133
- height: "100%",
134
- maxHeight: "100%",
135
- maxWidth: "100%"
136
- }));
137
- return (n, o) => (m(), I(u(J).div, de(n.$attrs, {
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: f,
272
+ ref: g,
273
+ as: n.as,
140
274
  style: {
141
- ...oe,
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
- overflow: e.overflow ? "visible" : "hidden"
279
+ ...De.value
144
280
  },
145
- onPointerenter: o[0] || (o[0] = () => {
146
- u(K)(u(b), n.hoverFactor);
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
- onPointerleave: o[1] || (o[1] = () => {
149
- u(K)(u(b), 1);
150
- })
292
+ onPointerdown: ze.value,
293
+ onDragEnd: Be.value
151
294
  }), {
152
- default: _(() => [W(u(J).ul, {
295
+ default: J(() => [z(c(Ze).ul, {
153
296
  ref_key: "listRef",
154
- ref: z,
155
- style: ve(ie.value)
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: _(() => [(m(!0), O(R, null, V(P.value, (i, s) => (m(), I(Q, {
158
- key: `original-${s}`,
159
- axis: j.value,
160
- offset: h.value,
161
- "list-size": N.value,
162
- "item-index": s,
163
- bounds: t.itemPositions[s] ?? u(U),
164
- inset: t.inset,
165
- "align-items": L.value,
166
- "item-size": n.itemSize
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: _(() => [(m(!0), O(R, null, V(u(X)([i]), (a, d) => (m(), I(E(a), {
169
- key: d
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", "inset", "align-items", "item-size"]))), 128)), (m(!0), O(R, null, V(ne.value, (i) => (m(), I(E(i), {
173
- key: i.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
- Ne as default
341
+ Pt as default
183
342
  };
@@ -1,52 +1,84 @@
1
- import { defineComponent as c, computed as f, createBlock as p, openBlock as x, unref as n, mergeProps as v, withCtx as S, renderSlot as h } from "vue";
2
- import { useTransform as l, motion as z } from "motion-v";
3
- import { provideTickerItemContext as I } from "./context.mjs";
4
- const C = /* @__PURE__ */ c({
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
- itemSize: { default: "auto" }
16
+ size: { default: "auto" },
17
+ safeMargin: {},
18
+ reproject: { type: Boolean, default: !0 }
16
19
  },
17
- setup(a) {
18
- const t = a, o = l(() => {
19
- const e = t.offset.get(), { start: i, end: s } = t.bounds;
20
- return !i && !s || !t.listSize ? 0 : e + s <= -t.inset ? t.listSize : 0;
21
- }), d = l(() => {
22
- const { start: e, end: i } = t.bounds, s = t.offset.get(), u = o.get();
23
- return !e && !i || !t.listSize ? 0 : s + e + u;
24
- }), r = f(
25
- () => t.alignItems === "stretch" ? "100%" : "fit-content"
26
- ), m = f(() => t.cloneIndex !== void 0);
27
- return I({
28
- offset: d
29
- }), (e, i) => (x(), p(n(z).li, v(e.$attrs, {
30
- class: e.cloneIndex === void 0 ? "ticker-item" : "clone-item",
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
- default: S(() => [
44
- h(e.$slots, "default")
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, ["class", "aria-hidden", "style"]));
79
+ }, 16));
48
80
  }
49
81
  });
50
82
  export {
51
- C as default
83
+ F as default
52
84
  };
@@ -1,8 +1,17 @@
1
- const t = { start: 0, end: 0 }, e = {
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
- e as alignAlias,
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 [o, r] = e("TickerItemContext");
2
+ const [t, o] = e("TickerItemContext"), [c, i] = e("TickerInfo");
3
3
  export {
4
- r as provideTickerItemContext,
5
- o as useTickerItemContext
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
+ };