@dogeos/dogeos-sdk 3.0.7-beta.3 → 3.0.7-beta.4
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/features-animation-Dc6ZFmM3.js +2509 -0
- package/dist/index-BZt4TkSe.js +1410 -0
- package/dist/index-DnuidqYy.js +5 -0
- package/dist/index-UJLT6A17.js +33962 -0
- package/dist/index.js +6 -5746
- package/dist/src-UW24ZMRV-D7nf-2D5.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
import { f as T, a as R, c as O, b as Ot, i as F, p as z, d as le, n as M, P as he, e as Ft, L as ce, S as ue, g as de, m as Nt, h as Gt, r as Wt, j as me, s as $, k as H, l as et } from "./index-UJLT6A17.js";
|
|
2
|
+
import { A as Zi, q as Ki, M as Ji, z as Qi, y as ts, w as es, v as is, u as ss, C as os, E as ns, t as as, o as rs, D as ls, x as hs, F as cs, B as us } from "./index-UJLT6A17.js";
|
|
3
|
+
import { i as fe, e as _t, p as pe, a as b, s as ge, m as ye, b as v, c as J, d as y, f as ve, g as xe, h as Pe, j as zt, k as it, l as $t, n as Te, F as Ht, o as st, q as De, r as ot, t as Xt, u as Se, S as Ee, v as Ae, w as V, x as N, y as G, z as nt, A as Re, B as Le, C as Ce, D as B, E as je, G as Ve } from "./features-animation-Dc6ZFmM3.js";
|
|
4
|
+
import { K as ms, N as fs, V as ps, a4 as gs, H as ys, a2 as vs, P as xs, Q as Ps, R as Ts, T as Ds, U as Ss, W as Es, J as As, _ as Rs, X as Ls, Y as Cs, Z as js, M as Vs, a1 as Bs, a3 as Ms, $ as ws, O as ks, a0 as bs, L as Us, I as Is } from "./features-animation-Dc6ZFmM3.js";
|
|
5
|
+
import { jsx as Be } from "react/jsx-runtime";
|
|
6
|
+
import { useContext as Q, useId as Me, useEffect as we, useCallback as ke, Component as be } from "react";
|
|
7
|
+
const at = (t, e) => Math.abs(t - e);
|
|
8
|
+
function Ue(t, e) {
|
|
9
|
+
const i = at(t.x, e.x), o = at(t.y, e.y);
|
|
10
|
+
return Math.sqrt(i ** 2 + o ** 2);
|
|
11
|
+
}
|
|
12
|
+
class Yt {
|
|
13
|
+
constructor(e, i, { transformPagePoint: o, contextWindow: r, dragSnapToOrigin: u = !1 } = {}) {
|
|
14
|
+
if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => {
|
|
15
|
+
if (!(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
16
|
+
return;
|
|
17
|
+
const c = Y(this.lastMoveEventInfo, this.history), d = this.startEvent !== null, m = Ue(c.offset, { x: 0, y: 0 }) >= 3;
|
|
18
|
+
if (!d && !m)
|
|
19
|
+
return;
|
|
20
|
+
const { point: p } = c, { timestamp: f } = T;
|
|
21
|
+
this.history.push({ ...p, timestamp: f });
|
|
22
|
+
const { onStart: g, onMove: x } = this.handlers;
|
|
23
|
+
d || (g && g(this.lastMoveEvent, c), this.startEvent = this.lastMoveEvent), x && x(this.lastMoveEvent, c);
|
|
24
|
+
}, this.handlePointerMove = (c, d) => {
|
|
25
|
+
this.lastMoveEvent = c, this.lastMoveEventInfo = X(d, this.transformPagePoint), R.update(this.updatePoint, !0);
|
|
26
|
+
}, this.handlePointerUp = (c, d) => {
|
|
27
|
+
this.end();
|
|
28
|
+
const { onEnd: m, onSessionEnd: p, resumeAnimation: f } = this.handlers;
|
|
29
|
+
if (this.dragSnapToOrigin && f && f(), !(this.lastMoveEvent && this.lastMoveEventInfo))
|
|
30
|
+
return;
|
|
31
|
+
const g = Y(c.type === "pointercancel" ? this.lastMoveEventInfo : X(d, this.transformPagePoint), this.history);
|
|
32
|
+
this.startEvent && m && m(c, g), p && p(c, g);
|
|
33
|
+
}, !fe(e))
|
|
34
|
+
return;
|
|
35
|
+
this.dragSnapToOrigin = u, this.handlers = i, this.transformPagePoint = o, this.contextWindow = r || window;
|
|
36
|
+
const s = _t(e), n = X(s, this.transformPagePoint), { point: a } = n, { timestamp: l } = T;
|
|
37
|
+
this.history = [{ ...a, timestamp: l }];
|
|
38
|
+
const { onSessionStart: h } = i;
|
|
39
|
+
h && h(e, Y(n, this.history)), this.removeListeners = pe(b(this.contextWindow, "pointermove", this.handlePointerMove), b(this.contextWindow, "pointerup", this.handlePointerUp), b(this.contextWindow, "pointercancel", this.handlePointerUp));
|
|
40
|
+
}
|
|
41
|
+
updateHandlers(e) {
|
|
42
|
+
this.handlers = e;
|
|
43
|
+
}
|
|
44
|
+
end() {
|
|
45
|
+
this.removeListeners && this.removeListeners(), O(this.updatePoint);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function X(t, e) {
|
|
49
|
+
return e ? { point: e(t.point) } : t;
|
|
50
|
+
}
|
|
51
|
+
function rt(t, e) {
|
|
52
|
+
return { x: t.x - e.x, y: t.y - e.y };
|
|
53
|
+
}
|
|
54
|
+
function Y({ point: t }, e) {
|
|
55
|
+
return {
|
|
56
|
+
point: t,
|
|
57
|
+
delta: rt(t, qt(e)),
|
|
58
|
+
offset: rt(t, Ie(e)),
|
|
59
|
+
velocity: Oe(e, 0.1)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function Ie(t) {
|
|
63
|
+
return t[0];
|
|
64
|
+
}
|
|
65
|
+
function qt(t) {
|
|
66
|
+
return t[t.length - 1];
|
|
67
|
+
}
|
|
68
|
+
function Oe(t, e) {
|
|
69
|
+
if (t.length < 2)
|
|
70
|
+
return { x: 0, y: 0 };
|
|
71
|
+
let i = t.length - 1, o = null;
|
|
72
|
+
const r = qt(t);
|
|
73
|
+
for (; i >= 0 && (o = t[i], !(r.timestamp - o.timestamp > ge(e))); )
|
|
74
|
+
i--;
|
|
75
|
+
if (!o)
|
|
76
|
+
return { x: 0, y: 0 };
|
|
77
|
+
const u = ye(r.timestamp - o.timestamp);
|
|
78
|
+
if (u === 0)
|
|
79
|
+
return { x: 0, y: 0 };
|
|
80
|
+
const s = {
|
|
81
|
+
x: (r.x - o.x) / u,
|
|
82
|
+
y: (r.y - o.y) / u
|
|
83
|
+
};
|
|
84
|
+
return s.x === 1 / 0 && (s.x = 0), s.y === 1 / 0 && (s.y = 0), s;
|
|
85
|
+
}
|
|
86
|
+
const Zt = 1e-4, Fe = 1 - Zt, Ne = 1 + Zt, Kt = 0.01, Ge = 0 - Kt, We = 0 + Kt;
|
|
87
|
+
function D(t) {
|
|
88
|
+
return t.max - t.min;
|
|
89
|
+
}
|
|
90
|
+
function _e(t, e, i) {
|
|
91
|
+
return Math.abs(t - e) <= i;
|
|
92
|
+
}
|
|
93
|
+
function lt(t, e, i, o = 0.5) {
|
|
94
|
+
t.origin = o, t.originPoint = v(e.min, e.max, t.origin), t.scale = D(i) / D(e), t.translate = v(i.min, i.max, t.origin) - t.originPoint, (t.scale >= Fe && t.scale <= Ne || isNaN(t.scale)) && (t.scale = 1), (t.translate >= Ge && t.translate <= We || isNaN(t.translate)) && (t.translate = 0);
|
|
95
|
+
}
|
|
96
|
+
function U(t, e, i, o) {
|
|
97
|
+
lt(t.x, e.x, i.x, o ? o.originX : void 0), lt(t.y, e.y, i.y, o ? o.originY : void 0);
|
|
98
|
+
}
|
|
99
|
+
function ht(t, e, i) {
|
|
100
|
+
t.min = i.min + e.min, t.max = t.min + D(e);
|
|
101
|
+
}
|
|
102
|
+
function ze(t, e, i) {
|
|
103
|
+
ht(t.x, e.x, i.x), ht(t.y, e.y, i.y);
|
|
104
|
+
}
|
|
105
|
+
function ct(t, e, i) {
|
|
106
|
+
t.min = e.min - i.min, t.max = t.min + D(e);
|
|
107
|
+
}
|
|
108
|
+
function I(t, e, i) {
|
|
109
|
+
ct(t.x, e.x, i.x), ct(t.y, e.y, i.y);
|
|
110
|
+
}
|
|
111
|
+
function $e(t, { min: e, max: i }, o) {
|
|
112
|
+
return e !== void 0 && t < e ? t = o ? v(e, t, o.min) : Math.max(t, e) : i !== void 0 && t > i && (t = o ? v(i, t, o.max) : Math.min(t, i)), t;
|
|
113
|
+
}
|
|
114
|
+
function ut(t, e, i) {
|
|
115
|
+
return {
|
|
116
|
+
min: e !== void 0 ? t.min + e : void 0,
|
|
117
|
+
max: i !== void 0 ? t.max + i - (t.max - t.min) : void 0
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function He(t, { top: e, left: i, bottom: o, right: r }) {
|
|
121
|
+
return {
|
|
122
|
+
x: ut(t.x, i, r),
|
|
123
|
+
y: ut(t.y, e, o)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function dt(t, e) {
|
|
127
|
+
let i = e.min - t.min, o = e.max - t.max;
|
|
128
|
+
return e.max - e.min < t.max - t.min && ([i, o] = [o, i]), { min: i, max: o };
|
|
129
|
+
}
|
|
130
|
+
function Xe(t, e) {
|
|
131
|
+
return {
|
|
132
|
+
x: dt(t.x, e.x),
|
|
133
|
+
y: dt(t.y, e.y)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function Ye(t, e) {
|
|
137
|
+
let i = 0.5;
|
|
138
|
+
const o = D(t), r = D(e);
|
|
139
|
+
return r > o ? i = J(e.min, e.max - o, t.min) : o > r && (i = J(t.min, t.max - r, e.min)), Ot(0, 1, i);
|
|
140
|
+
}
|
|
141
|
+
function qe(t, e) {
|
|
142
|
+
const i = {};
|
|
143
|
+
return e.min !== void 0 && (i.min = e.min - t.min), e.max !== void 0 && (i.max = e.max - t.min), i;
|
|
144
|
+
}
|
|
145
|
+
const tt = 0.35;
|
|
146
|
+
function Ze(t = tt) {
|
|
147
|
+
return t === !1 ? t = 0 : t === !0 && (t = tt), {
|
|
148
|
+
x: mt(t, "left", "right"),
|
|
149
|
+
y: mt(t, "top", "bottom")
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function mt(t, e, i) {
|
|
153
|
+
return {
|
|
154
|
+
min: ft(t, e),
|
|
155
|
+
max: ft(t, i)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function ft(t, e) {
|
|
159
|
+
return typeof t == "number" ? t : t[e] || 0;
|
|
160
|
+
}
|
|
161
|
+
function A(t) {
|
|
162
|
+
return [t("x"), t("y")];
|
|
163
|
+
}
|
|
164
|
+
const Jt = ({ current: t }) => t ? t.ownerDocument.defaultView : null, Ke = /* @__PURE__ */ new WeakMap();
|
|
165
|
+
class Je {
|
|
166
|
+
constructor(e) {
|
|
167
|
+
this.openGlobalLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = y(), this.visualElement = e;
|
|
168
|
+
}
|
|
169
|
+
start(e, { snapToCursor: i = !1 } = {}) {
|
|
170
|
+
const { presenceContext: o } = this.visualElement;
|
|
171
|
+
if (o && o.isPresent === !1)
|
|
172
|
+
return;
|
|
173
|
+
const r = (h) => {
|
|
174
|
+
const { dragSnapToOrigin: c } = this.getProps();
|
|
175
|
+
c ? this.pauseAnimation() : this.stopAnimation(), i && this.snapToCursor(_t(h, "page").point);
|
|
176
|
+
}, u = (h, c) => {
|
|
177
|
+
var d;
|
|
178
|
+
const { drag: m, dragPropagation: p, onDragStart: f } = this.getProps();
|
|
179
|
+
if (m && !p && (this.openGlobalLock && this.openGlobalLock(), this.openGlobalLock = Te(m), !this.openGlobalLock))
|
|
180
|
+
return;
|
|
181
|
+
this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), A((x) => {
|
|
182
|
+
let L = this.getAxisMotionValue(x).get() || 0;
|
|
183
|
+
if (z.test(L)) {
|
|
184
|
+
const { projection: P } = this.visualElement;
|
|
185
|
+
if (P && P.layout) {
|
|
186
|
+
const S = P.layout.layoutBox[x];
|
|
187
|
+
S && (L = D(S) * (parseFloat(L) / 100));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
this.originPoint[x] = L;
|
|
191
|
+
}), f && R.postRender(() => f(h, c)), (d = this.removeWillChange) === null || d === void 0 || d.call(this), this.removeWillChange = it(this.visualElement, "transform");
|
|
192
|
+
const { animationState: g } = this.visualElement;
|
|
193
|
+
g && g.setActive("whileDrag", !0);
|
|
194
|
+
}, s = (h, c) => {
|
|
195
|
+
const { dragPropagation: d, dragDirectionLock: m, onDirectionLock: p, onDrag: f } = this.getProps();
|
|
196
|
+
if (!d && !this.openGlobalLock)
|
|
197
|
+
return;
|
|
198
|
+
const { offset: g } = c;
|
|
199
|
+
if (m && this.currentDirection === null) {
|
|
200
|
+
this.currentDirection = Qe(g), this.currentDirection !== null && p && p(this.currentDirection);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.updateAxis("x", c.point, g), this.updateAxis("y", c.point, g), this.visualElement.render(), f && f(h, c);
|
|
204
|
+
}, n = (h, c) => this.stop(h, c), a = () => A((h) => {
|
|
205
|
+
var c;
|
|
206
|
+
return this.getAnimationState(h) === "paused" && ((c = this.getAxisMotionValue(h).animation) === null || c === void 0 ? void 0 : c.play());
|
|
207
|
+
}), { dragSnapToOrigin: l } = this.getProps();
|
|
208
|
+
this.panSession = new Yt(e, {
|
|
209
|
+
onSessionStart: r,
|
|
210
|
+
onStart: u,
|
|
211
|
+
onMove: s,
|
|
212
|
+
onSessionEnd: n,
|
|
213
|
+
resumeAnimation: a
|
|
214
|
+
}, {
|
|
215
|
+
transformPagePoint: this.visualElement.getTransformPagePoint(),
|
|
216
|
+
dragSnapToOrigin: l,
|
|
217
|
+
contextWindow: Jt(this.visualElement)
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
stop(e, i) {
|
|
221
|
+
var o;
|
|
222
|
+
(o = this.removeWillChange) === null || o === void 0 || o.call(this);
|
|
223
|
+
const r = this.isDragging;
|
|
224
|
+
if (this.cancel(), !r)
|
|
225
|
+
return;
|
|
226
|
+
const { velocity: u } = i;
|
|
227
|
+
this.startAnimation(u);
|
|
228
|
+
const { onDragEnd: s } = this.getProps();
|
|
229
|
+
s && R.postRender(() => s(e, i));
|
|
230
|
+
}
|
|
231
|
+
cancel() {
|
|
232
|
+
this.isDragging = !1;
|
|
233
|
+
const { projection: e, animationState: i } = this.visualElement;
|
|
234
|
+
e && (e.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0;
|
|
235
|
+
const { dragPropagation: o } = this.getProps();
|
|
236
|
+
!o && this.openGlobalLock && (this.openGlobalLock(), this.openGlobalLock = null), i && i.setActive("whileDrag", !1);
|
|
237
|
+
}
|
|
238
|
+
updateAxis(e, i, o) {
|
|
239
|
+
const { drag: r } = this.getProps();
|
|
240
|
+
if (!o || !W(e, r, this.currentDirection))
|
|
241
|
+
return;
|
|
242
|
+
const u = this.getAxisMotionValue(e);
|
|
243
|
+
let s = this.originPoint[e] + o[e];
|
|
244
|
+
this.constraints && this.constraints[e] && (s = $e(s, this.constraints[e], this.elastic[e])), u.set(s);
|
|
245
|
+
}
|
|
246
|
+
resolveConstraints() {
|
|
247
|
+
var e;
|
|
248
|
+
const { dragConstraints: i, dragElastic: o } = this.getProps(), r = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : (e = this.visualElement.projection) === null || e === void 0 ? void 0 : e.layout, u = this.constraints;
|
|
249
|
+
i && F(i) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : i && r ? this.constraints = He(r.layoutBox, i) : this.constraints = !1, this.elastic = Ze(o), u !== this.constraints && r && this.constraints && !this.hasMutatedConstraints && A((s) => {
|
|
250
|
+
this.constraints !== !1 && this.getAxisMotionValue(s) && (this.constraints[s] = qe(r.layoutBox[s], this.constraints[s]));
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
resolveRefConstraints() {
|
|
254
|
+
const { dragConstraints: e, onMeasureDragConstraints: i } = this.getProps();
|
|
255
|
+
if (!e || !F(e))
|
|
256
|
+
return !1;
|
|
257
|
+
const o = e.current;
|
|
258
|
+
le(o !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
259
|
+
const { projection: r } = this.visualElement;
|
|
260
|
+
if (!r || !r.layout)
|
|
261
|
+
return !1;
|
|
262
|
+
const u = ve(o, r.root, this.visualElement.getTransformPagePoint());
|
|
263
|
+
let s = Xe(r.layout.layoutBox, u);
|
|
264
|
+
if (i) {
|
|
265
|
+
const n = i(xe(s));
|
|
266
|
+
this.hasMutatedConstraints = !!n, n && (s = Pe(n));
|
|
267
|
+
}
|
|
268
|
+
return s;
|
|
269
|
+
}
|
|
270
|
+
startAnimation(e) {
|
|
271
|
+
const { drag: i, dragMomentum: o, dragElastic: r, dragTransition: u, dragSnapToOrigin: s, onDragTransitionEnd: n } = this.getProps(), a = this.constraints || {}, l = A((h) => {
|
|
272
|
+
if (!W(h, i, this.currentDirection))
|
|
273
|
+
return;
|
|
274
|
+
let c = a && a[h] || {};
|
|
275
|
+
s && (c = { min: 0, max: 0 });
|
|
276
|
+
const d = r ? 200 : 1e6, m = r ? 40 : 1e7, p = {
|
|
277
|
+
type: "inertia",
|
|
278
|
+
velocity: o ? e[h] : 0,
|
|
279
|
+
bounceStiffness: d,
|
|
280
|
+
bounceDamping: m,
|
|
281
|
+
timeConstant: 750,
|
|
282
|
+
restDelta: 1,
|
|
283
|
+
restSpeed: 10,
|
|
284
|
+
...u,
|
|
285
|
+
...c
|
|
286
|
+
};
|
|
287
|
+
return this.startAxisValueAnimation(h, p);
|
|
288
|
+
});
|
|
289
|
+
return Promise.all(l).then(n);
|
|
290
|
+
}
|
|
291
|
+
startAxisValueAnimation(e, i) {
|
|
292
|
+
const o = this.getAxisMotionValue(e);
|
|
293
|
+
return o.start(zt(e, o, 0, i, this.visualElement, !1, it(this.visualElement, e)));
|
|
294
|
+
}
|
|
295
|
+
stopAnimation() {
|
|
296
|
+
A((e) => this.getAxisMotionValue(e).stop());
|
|
297
|
+
}
|
|
298
|
+
pauseAnimation() {
|
|
299
|
+
A((e) => {
|
|
300
|
+
var i;
|
|
301
|
+
return (i = this.getAxisMotionValue(e).animation) === null || i === void 0 ? void 0 : i.pause();
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
getAnimationState(e) {
|
|
305
|
+
var i;
|
|
306
|
+
return (i = this.getAxisMotionValue(e).animation) === null || i === void 0 ? void 0 : i.state;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Drag works differently depending on which props are provided.
|
|
310
|
+
*
|
|
311
|
+
* - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
|
|
312
|
+
* - Otherwise, we apply the delta to the x/y motion values.
|
|
313
|
+
*/
|
|
314
|
+
getAxisMotionValue(e) {
|
|
315
|
+
const i = `_drag${e.toUpperCase()}`, o = this.visualElement.getProps(), r = o[i];
|
|
316
|
+
return r || this.visualElement.getValue(e, (o.initial ? o.initial[e] : void 0) || 0);
|
|
317
|
+
}
|
|
318
|
+
snapToCursor(e) {
|
|
319
|
+
A((i) => {
|
|
320
|
+
const { drag: o } = this.getProps();
|
|
321
|
+
if (!W(i, o, this.currentDirection))
|
|
322
|
+
return;
|
|
323
|
+
const { projection: r } = this.visualElement, u = this.getAxisMotionValue(i);
|
|
324
|
+
if (r && r.layout) {
|
|
325
|
+
const { min: s, max: n } = r.layout.layoutBox[i];
|
|
326
|
+
u.set(e[i] - v(s, n, 0.5));
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* When the viewport resizes we want to check if the measured constraints
|
|
332
|
+
* have changed and, if so, reposition the element within those new constraints
|
|
333
|
+
* relative to where it was before the resize.
|
|
334
|
+
*/
|
|
335
|
+
scalePositionWithinConstraints() {
|
|
336
|
+
if (!this.visualElement.current)
|
|
337
|
+
return;
|
|
338
|
+
const { drag: e, dragConstraints: i } = this.getProps(), { projection: o } = this.visualElement;
|
|
339
|
+
if (!F(i) || !o || !this.constraints)
|
|
340
|
+
return;
|
|
341
|
+
this.stopAnimation();
|
|
342
|
+
const r = { x: 0, y: 0 };
|
|
343
|
+
A((s) => {
|
|
344
|
+
const n = this.getAxisMotionValue(s);
|
|
345
|
+
if (n && this.constraints !== !1) {
|
|
346
|
+
const a = n.get();
|
|
347
|
+
r[s] = Ye({ min: a, max: a }, this.constraints[s]);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
const { transformTemplate: u } = this.visualElement.getProps();
|
|
351
|
+
this.visualElement.current.style.transform = u ? u({}, "") : "none", o.root && o.root.updateScroll(), o.updateLayout(), this.resolveConstraints(), A((s) => {
|
|
352
|
+
if (!W(s, e, null))
|
|
353
|
+
return;
|
|
354
|
+
const n = this.getAxisMotionValue(s), { min: a, max: l } = this.constraints[s];
|
|
355
|
+
n.set(v(a, l, r[s]));
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
addListeners() {
|
|
359
|
+
if (!this.visualElement.current)
|
|
360
|
+
return;
|
|
361
|
+
Ke.set(this.visualElement, this);
|
|
362
|
+
const e = this.visualElement.current, i = b(e, "pointerdown", (a) => {
|
|
363
|
+
const { drag: l, dragListener: h = !0 } = this.getProps();
|
|
364
|
+
l && h && this.start(a);
|
|
365
|
+
}), o = () => {
|
|
366
|
+
const { dragConstraints: a } = this.getProps();
|
|
367
|
+
F(a) && a.current && (this.constraints = this.resolveRefConstraints());
|
|
368
|
+
}, { projection: r } = this.visualElement, u = r.addEventListener("measure", o);
|
|
369
|
+
r && !r.layout && (r.root && r.root.updateScroll(), r.updateLayout()), R.read(o);
|
|
370
|
+
const s = $t(window, "resize", () => this.scalePositionWithinConstraints()), n = r.addEventListener("didUpdate", ({ delta: a, hasLayoutChanged: l }) => {
|
|
371
|
+
this.isDragging && l && (A((h) => {
|
|
372
|
+
const c = this.getAxisMotionValue(h);
|
|
373
|
+
c && (this.originPoint[h] += a[h].translate, c.set(c.get() + a[h].translate));
|
|
374
|
+
}), this.visualElement.render());
|
|
375
|
+
});
|
|
376
|
+
return () => {
|
|
377
|
+
s(), i(), u(), n && n();
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
getProps() {
|
|
381
|
+
const e = this.visualElement.getProps(), { drag: i = !1, dragDirectionLock: o = !1, dragPropagation: r = !1, dragConstraints: u = !1, dragElastic: s = tt, dragMomentum: n = !0 } = e;
|
|
382
|
+
return {
|
|
383
|
+
...e,
|
|
384
|
+
drag: i,
|
|
385
|
+
dragDirectionLock: o,
|
|
386
|
+
dragPropagation: r,
|
|
387
|
+
dragConstraints: u,
|
|
388
|
+
dragElastic: s,
|
|
389
|
+
dragMomentum: n
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function W(t, e, i) {
|
|
394
|
+
return (e === !0 || e === t) && (i === null || i === t);
|
|
395
|
+
}
|
|
396
|
+
function Qe(t, e = 10) {
|
|
397
|
+
let i = null;
|
|
398
|
+
return Math.abs(t.y) > e ? i = "y" : Math.abs(t.x) > e && (i = "x"), i;
|
|
399
|
+
}
|
|
400
|
+
class ti extends Ht {
|
|
401
|
+
constructor(e) {
|
|
402
|
+
super(e), this.removeGroupControls = M, this.removeListeners = M, this.controls = new Je(e);
|
|
403
|
+
}
|
|
404
|
+
mount() {
|
|
405
|
+
const { dragControls: e } = this.node.getProps();
|
|
406
|
+
e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || M;
|
|
407
|
+
}
|
|
408
|
+
unmount() {
|
|
409
|
+
this.removeGroupControls(), this.removeListeners();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const pt = (t) => (e, i) => {
|
|
413
|
+
t && R.postRender(() => t(e, i));
|
|
414
|
+
};
|
|
415
|
+
class ei extends Ht {
|
|
416
|
+
constructor() {
|
|
417
|
+
super(...arguments), this.removePointerDownListener = M;
|
|
418
|
+
}
|
|
419
|
+
onPointerDown(e) {
|
|
420
|
+
this.session = new Yt(e, this.createPanHandlers(), {
|
|
421
|
+
transformPagePoint: this.node.getTransformPagePoint(),
|
|
422
|
+
contextWindow: Jt(this.node)
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
createPanHandlers() {
|
|
426
|
+
const { onPanSessionStart: e, onPanStart: i, onPan: o, onPanEnd: r } = this.node.getProps();
|
|
427
|
+
return {
|
|
428
|
+
onSessionStart: pt(e),
|
|
429
|
+
onStart: pt(i),
|
|
430
|
+
onMove: o,
|
|
431
|
+
onEnd: (u, s) => {
|
|
432
|
+
delete this.session, r && R.postRender(() => r(u, s));
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
mount() {
|
|
437
|
+
this.removePointerDownListener = b(this.node.current, "pointerdown", (e) => this.onPointerDown(e));
|
|
438
|
+
}
|
|
439
|
+
update() {
|
|
440
|
+
this.session && this.session.updateHandlers(this.createPanHandlers());
|
|
441
|
+
}
|
|
442
|
+
unmount() {
|
|
443
|
+
this.removePointerDownListener(), this.session && this.session.end();
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function ii() {
|
|
447
|
+
const t = Q(he);
|
|
448
|
+
if (t === null)
|
|
449
|
+
return [!0, null];
|
|
450
|
+
const { isPresent: e, onExitComplete: i, register: o } = t, r = Me();
|
|
451
|
+
we(() => o(r), []);
|
|
452
|
+
const u = ke(() => i && i(r), [r, i]);
|
|
453
|
+
return !e && i ? [!1, u] : [!0];
|
|
454
|
+
}
|
|
455
|
+
const _ = {
|
|
456
|
+
/**
|
|
457
|
+
* Global flag as to whether the tree has animated since the last time
|
|
458
|
+
* we resized the window
|
|
459
|
+
*/
|
|
460
|
+
hasAnimatedSinceResize: !0,
|
|
461
|
+
/**
|
|
462
|
+
* We set this to true once, on the first update. Any nodes added to the tree beyond that
|
|
463
|
+
* update will be given a `data-projection-id` attribute.
|
|
464
|
+
*/
|
|
465
|
+
hasEverUpdated: !1
|
|
466
|
+
};
|
|
467
|
+
function gt(t, e) {
|
|
468
|
+
return e.max === e.min ? 0 : t / (e.max - e.min) * 100;
|
|
469
|
+
}
|
|
470
|
+
const w = {
|
|
471
|
+
correct: (t, e) => {
|
|
472
|
+
if (!e.target)
|
|
473
|
+
return t;
|
|
474
|
+
if (typeof t == "string")
|
|
475
|
+
if (Ft.test(t))
|
|
476
|
+
t = parseFloat(t);
|
|
477
|
+
else
|
|
478
|
+
return t;
|
|
479
|
+
const i = gt(t, e.target.x), o = gt(t, e.target.y);
|
|
480
|
+
return `${i}% ${o}%`;
|
|
481
|
+
}
|
|
482
|
+
}, si = {
|
|
483
|
+
correct: (t, { treeScale: e, projectionDelta: i }) => {
|
|
484
|
+
const o = t, r = st.parse(t);
|
|
485
|
+
if (r.length > 5)
|
|
486
|
+
return o;
|
|
487
|
+
const u = st.createTransformer(t), s = typeof r[0] != "number" ? 1 : 0, n = i.x.scale * e.x, a = i.y.scale * e.y;
|
|
488
|
+
r[0 + s] /= n, r[1 + s] /= a;
|
|
489
|
+
const l = v(n, a, 0.5);
|
|
490
|
+
return typeof r[2 + s] == "number" && (r[2 + s] /= l), typeof r[3 + s] == "number" && (r[3 + s] /= l), u(r);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
class oi extends be {
|
|
494
|
+
/**
|
|
495
|
+
* This only mounts projection nodes for components that
|
|
496
|
+
* need measuring, we might want to do it for all components
|
|
497
|
+
* in order to incorporate transforms
|
|
498
|
+
*/
|
|
499
|
+
componentDidMount() {
|
|
500
|
+
const { visualElement: e, layoutGroup: i, switchLayoutGroup: o, layoutId: r } = this.props, { projection: u } = e;
|
|
501
|
+
de(ni), u && (i.group && i.group.add(u), o && o.register && r && o.register(u), u.root.didUpdate(), u.addEventListener("animationComplete", () => {
|
|
502
|
+
this.safeToRemove();
|
|
503
|
+
}), u.setOptions({
|
|
504
|
+
...u.options,
|
|
505
|
+
onExitComplete: () => this.safeToRemove()
|
|
506
|
+
})), _.hasEverUpdated = !0;
|
|
507
|
+
}
|
|
508
|
+
getSnapshotBeforeUpdate(e) {
|
|
509
|
+
const { layoutDependency: i, visualElement: o, drag: r, isPresent: u } = this.props, s = o.projection;
|
|
510
|
+
return s && (s.isPresent = u, r || e.layoutDependency !== i || i === void 0 ? s.willUpdate() : this.safeToRemove(), e.isPresent !== u && (u ? s.promote() : s.relegate() || R.postRender(() => {
|
|
511
|
+
const n = s.getStack();
|
|
512
|
+
(!n || !n.members.length) && this.safeToRemove();
|
|
513
|
+
}))), null;
|
|
514
|
+
}
|
|
515
|
+
componentDidUpdate() {
|
|
516
|
+
const { projection: e } = this.props.visualElement;
|
|
517
|
+
e && (e.root.didUpdate(), Nt.postRender(() => {
|
|
518
|
+
!e.currentAnimation && e.isLead() && this.safeToRemove();
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
componentWillUnmount() {
|
|
522
|
+
const { visualElement: e, layoutGroup: i, switchLayoutGroup: o } = this.props, { projection: r } = e;
|
|
523
|
+
r && (r.scheduleCheckAfterUnmount(), i && i.group && i.group.remove(r), o && o.deregister && o.deregister(r));
|
|
524
|
+
}
|
|
525
|
+
safeToRemove() {
|
|
526
|
+
const { safeToRemove: e } = this.props;
|
|
527
|
+
e && e();
|
|
528
|
+
}
|
|
529
|
+
render() {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function Qt(t) {
|
|
534
|
+
const [e, i] = ii(), o = Q(ce);
|
|
535
|
+
return Be(oi, { ...t, layoutGroup: o, switchLayoutGroup: Q(ue), isPresent: e, safeToRemove: i });
|
|
536
|
+
}
|
|
537
|
+
const ni = {
|
|
538
|
+
borderRadius: {
|
|
539
|
+
...w,
|
|
540
|
+
applyTo: [
|
|
541
|
+
"borderTopLeftRadius",
|
|
542
|
+
"borderTopRightRadius",
|
|
543
|
+
"borderBottomLeftRadius",
|
|
544
|
+
"borderBottomRightRadius"
|
|
545
|
+
]
|
|
546
|
+
},
|
|
547
|
+
borderTopLeftRadius: w,
|
|
548
|
+
borderTopRightRadius: w,
|
|
549
|
+
borderBottomLeftRadius: w,
|
|
550
|
+
borderBottomRightRadius: w,
|
|
551
|
+
boxShadow: si
|
|
552
|
+
}, te = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], ai = te.length, yt = (t) => typeof t == "string" ? parseFloat(t) : t, vt = (t) => typeof t == "number" || Ft.test(t);
|
|
553
|
+
function ri(t, e, i, o, r, u) {
|
|
554
|
+
r ? (t.opacity = v(
|
|
555
|
+
0,
|
|
556
|
+
// TODO Reinstate this if only child
|
|
557
|
+
i.opacity !== void 0 ? i.opacity : 1,
|
|
558
|
+
li(o)
|
|
559
|
+
), t.opacityExit = v(e.opacity !== void 0 ? e.opacity : 1, 0, hi(o))) : u && (t.opacity = v(e.opacity !== void 0 ? e.opacity : 1, i.opacity !== void 0 ? i.opacity : 1, o));
|
|
560
|
+
for (let s = 0; s < ai; s++) {
|
|
561
|
+
const n = `border${te[s]}Radius`;
|
|
562
|
+
let a = xt(e, n), l = xt(i, n);
|
|
563
|
+
if (a === void 0 && l === void 0)
|
|
564
|
+
continue;
|
|
565
|
+
a || (a = 0), l || (l = 0), a === 0 || l === 0 || vt(a) === vt(l) ? (t[n] = Math.max(v(yt(a), yt(l), o), 0), (z.test(l) || z.test(a)) && (t[n] += "%")) : t[n] = l;
|
|
566
|
+
}
|
|
567
|
+
(e.rotate || i.rotate) && (t.rotate = v(e.rotate || 0, i.rotate || 0, o));
|
|
568
|
+
}
|
|
569
|
+
function xt(t, e) {
|
|
570
|
+
return t[e] !== void 0 ? t[e] : t.borderRadius;
|
|
571
|
+
}
|
|
572
|
+
const li = /* @__PURE__ */ ee(0, 0.5, De), hi = /* @__PURE__ */ ee(0.5, 0.95, M);
|
|
573
|
+
function ee(t, e, i) {
|
|
574
|
+
return (o) => o < t ? 0 : o > e ? 1 : i(J(t, e, o));
|
|
575
|
+
}
|
|
576
|
+
function Pt(t, e) {
|
|
577
|
+
t.min = e.min, t.max = e.max;
|
|
578
|
+
}
|
|
579
|
+
function E(t, e) {
|
|
580
|
+
Pt(t.x, e.x), Pt(t.y, e.y);
|
|
581
|
+
}
|
|
582
|
+
function Tt(t, e) {
|
|
583
|
+
t.translate = e.translate, t.scale = e.scale, t.originPoint = e.originPoint, t.origin = e.origin;
|
|
584
|
+
}
|
|
585
|
+
function Dt(t, e, i, o, r) {
|
|
586
|
+
return t -= e, t = ot(t, 1 / i, o), r !== void 0 && (t = ot(t, 1 / r, o)), t;
|
|
587
|
+
}
|
|
588
|
+
function ci(t, e = 0, i = 1, o = 0.5, r, u = t, s = t) {
|
|
589
|
+
if (z.test(e) && (e = parseFloat(e), e = v(s.min, s.max, e / 100) - s.min), typeof e != "number")
|
|
590
|
+
return;
|
|
591
|
+
let n = v(u.min, u.max, o);
|
|
592
|
+
t === u && (n -= e), t.min = Dt(t.min, e, i, n, r), t.max = Dt(t.max, e, i, n, r);
|
|
593
|
+
}
|
|
594
|
+
function St(t, e, [i, o, r], u, s) {
|
|
595
|
+
ci(t, e[i], e[o], e[r], e.scale, u, s);
|
|
596
|
+
}
|
|
597
|
+
const ui = ["x", "scaleX", "originX"], di = ["y", "scaleY", "originY"];
|
|
598
|
+
function Et(t, e, i, o) {
|
|
599
|
+
St(t.x, e, ui, i ? i.x : void 0, o ? o.x : void 0), St(t.y, e, di, i ? i.y : void 0, o ? o.y : void 0);
|
|
600
|
+
}
|
|
601
|
+
function At(t) {
|
|
602
|
+
return t.translate === 0 && t.scale === 1;
|
|
603
|
+
}
|
|
604
|
+
function ie(t) {
|
|
605
|
+
return At(t.x) && At(t.y);
|
|
606
|
+
}
|
|
607
|
+
function Rt(t, e) {
|
|
608
|
+
return t.min === e.min && t.max === e.max;
|
|
609
|
+
}
|
|
610
|
+
function mi(t, e) {
|
|
611
|
+
return Rt(t.x, e.x) && Rt(t.y, e.y);
|
|
612
|
+
}
|
|
613
|
+
function Lt(t, e) {
|
|
614
|
+
return Math.round(t.min) === Math.round(e.min) && Math.round(t.max) === Math.round(e.max);
|
|
615
|
+
}
|
|
616
|
+
function se(t, e) {
|
|
617
|
+
return Lt(t.x, e.x) && Lt(t.y, e.y);
|
|
618
|
+
}
|
|
619
|
+
function Ct(t) {
|
|
620
|
+
return D(t.x) / D(t.y);
|
|
621
|
+
}
|
|
622
|
+
function jt(t, e) {
|
|
623
|
+
return t.translate === e.translate && t.scale === e.scale && t.originPoint === e.originPoint;
|
|
624
|
+
}
|
|
625
|
+
class fi {
|
|
626
|
+
constructor() {
|
|
627
|
+
this.members = [];
|
|
628
|
+
}
|
|
629
|
+
add(e) {
|
|
630
|
+
Gt(this.members, e), e.scheduleRender();
|
|
631
|
+
}
|
|
632
|
+
remove(e) {
|
|
633
|
+
if (Wt(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) {
|
|
634
|
+
const i = this.members[this.members.length - 1];
|
|
635
|
+
i && this.promote(i);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
relegate(e) {
|
|
639
|
+
const i = this.members.findIndex((r) => e === r);
|
|
640
|
+
if (i === 0)
|
|
641
|
+
return !1;
|
|
642
|
+
let o;
|
|
643
|
+
for (let r = i; r >= 0; r--) {
|
|
644
|
+
const u = this.members[r];
|
|
645
|
+
if (u.isPresent !== !1) {
|
|
646
|
+
o = u;
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return o ? (this.promote(o), !0) : !1;
|
|
651
|
+
}
|
|
652
|
+
promote(e, i) {
|
|
653
|
+
const o = this.lead;
|
|
654
|
+
if (e !== o && (this.prevLead = o, this.lead = e, e.show(), o)) {
|
|
655
|
+
o.instance && o.scheduleRender(), e.scheduleRender(), e.resumeFrom = o, i && (e.resumeFrom.preserveOpacity = !0), o.snapshot && (e.snapshot = o.snapshot, e.snapshot.latestValues = o.animationValues || o.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0);
|
|
656
|
+
const { crossfade: r } = e.options;
|
|
657
|
+
r === !1 && o.hide();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
exitAnimationComplete() {
|
|
661
|
+
this.members.forEach((e) => {
|
|
662
|
+
const { options: i, resumingFrom: o } = e;
|
|
663
|
+
i.onExitComplete && i.onExitComplete(), o && o.options.onExitComplete && o.options.onExitComplete();
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
scheduleRender() {
|
|
667
|
+
this.members.forEach((e) => {
|
|
668
|
+
e.instance && e.scheduleRender(!1);
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Clear any leads that have been removed this render to prevent them from being
|
|
673
|
+
* used in future animations and to prevent memory leaks
|
|
674
|
+
*/
|
|
675
|
+
removeLeadSnapshot() {
|
|
676
|
+
this.lead && this.lead.snapshot && (this.lead.snapshot = void 0);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function pi(t, e, i) {
|
|
680
|
+
let o = "";
|
|
681
|
+
const r = t.x.translate / e.x, u = t.y.translate / e.y, s = i?.z || 0;
|
|
682
|
+
if ((r || u || s) && (o = `translate3d(${r}px, ${u}px, ${s}px) `), (e.x !== 1 || e.y !== 1) && (o += `scale(${1 / e.x}, ${1 / e.y}) `), i) {
|
|
683
|
+
const { transformPerspective: l, rotate: h, rotateX: c, rotateY: d, skewX: m, skewY: p } = i;
|
|
684
|
+
l && (o = `perspective(${l}px) ${o}`), h && (o += `rotate(${h}deg) `), c && (o += `rotateX(${c}deg) `), d && (o += `rotateY(${d}deg) `), m && (o += `skewX(${m}deg) `), p && (o += `skewY(${p}deg) `);
|
|
685
|
+
}
|
|
686
|
+
const n = t.x.scale * e.x, a = t.y.scale * e.y;
|
|
687
|
+
return (n !== 1 || a !== 1) && (o += `scale(${n}, ${a})`), o || "none";
|
|
688
|
+
}
|
|
689
|
+
const gi = (t, e) => t.depth - e.depth;
|
|
690
|
+
class yi {
|
|
691
|
+
constructor() {
|
|
692
|
+
this.children = [], this.isDirty = !1;
|
|
693
|
+
}
|
|
694
|
+
add(e) {
|
|
695
|
+
Gt(this.children, e), this.isDirty = !0;
|
|
696
|
+
}
|
|
697
|
+
remove(e) {
|
|
698
|
+
Wt(this.children, e), this.isDirty = !0;
|
|
699
|
+
}
|
|
700
|
+
forEach(e) {
|
|
701
|
+
this.isDirty && this.children.sort(gi), this.isDirty = !1, this.children.forEach(e);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function vi(t, e) {
|
|
705
|
+
const i = Xt.now(), o = ({ timestamp: r }) => {
|
|
706
|
+
const u = r - i;
|
|
707
|
+
u >= e && (O(o), t(u - e));
|
|
708
|
+
};
|
|
709
|
+
return R.read(o, !0), () => O(o);
|
|
710
|
+
}
|
|
711
|
+
function xi(t) {
|
|
712
|
+
return t instanceof SVGElement && t.tagName !== "svg";
|
|
713
|
+
}
|
|
714
|
+
function Pi(t, e, i) {
|
|
715
|
+
const o = me(t) ? t : Se(t);
|
|
716
|
+
return o.start(zt("", o, e, i)), o.animation;
|
|
717
|
+
}
|
|
718
|
+
const C = {
|
|
719
|
+
type: "projectionFrame",
|
|
720
|
+
totalNodes: 0,
|
|
721
|
+
resolvedTargetDeltas: 0,
|
|
722
|
+
recalculatedProjection: 0
|
|
723
|
+
}, k = typeof window < "u" && window.MotionDebug !== void 0, q = ["", "X", "Y", "Z"], Ti = { visibility: "hidden" }, Vt = 1e3;
|
|
724
|
+
let Di = 0;
|
|
725
|
+
function Z(t, e, i, o) {
|
|
726
|
+
const { latestValues: r } = e;
|
|
727
|
+
r[t] && (i[t] = r[t], e.setStaticValue(t, 0), o && (o[t] = 0));
|
|
728
|
+
}
|
|
729
|
+
function oe(t) {
|
|
730
|
+
if (t.hasCheckedOptimisedAppear = !0, t.root === t)
|
|
731
|
+
return;
|
|
732
|
+
const { visualElement: e } = t.options;
|
|
733
|
+
if (!e)
|
|
734
|
+
return;
|
|
735
|
+
const i = je(e);
|
|
736
|
+
if (window.MotionHasOptimisedAnimation(i, "transform")) {
|
|
737
|
+
const { layout: r, layoutId: u } = t.options;
|
|
738
|
+
window.MotionCancelOptimisedAnimation(i, "transform", R, !(r || u));
|
|
739
|
+
}
|
|
740
|
+
const { parent: o } = t;
|
|
741
|
+
o && !o.hasCheckedOptimisedAppear && oe(o);
|
|
742
|
+
}
|
|
743
|
+
function ne({ attachResizeListener: t, defaultParent: e, measureScroll: i, checkIsScrollRoot: o, resetTransform: r }) {
|
|
744
|
+
return class {
|
|
745
|
+
constructor(s = {}, n = e?.()) {
|
|
746
|
+
this.id = Di++, this.animationId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.hasCheckedOptimisedAppear = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.updateScheduled = !1, this.scheduleUpdate = () => this.update(), this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => {
|
|
747
|
+
this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots());
|
|
748
|
+
}, this.updateProjection = () => {
|
|
749
|
+
this.projectionUpdateScheduled = !1, k && (C.totalNodes = C.resolvedTargetDeltas = C.recalculatedProjection = 0), this.nodes.forEach(Ai), this.nodes.forEach(Vi), this.nodes.forEach(Bi), this.nodes.forEach(Ri), k && window.MotionDebug.record(C);
|
|
750
|
+
}, this.resolvedRelativeTargetAt = 0, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = s, this.root = n ? n.root || n : this, this.path = n ? [...n.path, n] : [], this.parent = n, this.depth = n ? n.depth + 1 : 0;
|
|
751
|
+
for (let a = 0; a < this.path.length; a++)
|
|
752
|
+
this.path[a].shouldResetTransform = !0;
|
|
753
|
+
this.root === this && (this.nodes = new yi());
|
|
754
|
+
}
|
|
755
|
+
addEventListener(s, n) {
|
|
756
|
+
return this.eventHandlers.has(s) || this.eventHandlers.set(s, new Ee()), this.eventHandlers.get(s).add(n);
|
|
757
|
+
}
|
|
758
|
+
notifyListeners(s, ...n) {
|
|
759
|
+
const a = this.eventHandlers.get(s);
|
|
760
|
+
a && a.notify(...n);
|
|
761
|
+
}
|
|
762
|
+
hasListeners(s) {
|
|
763
|
+
return this.eventHandlers.has(s);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Lifecycles
|
|
767
|
+
*/
|
|
768
|
+
mount(s, n = this.root.hasTreeAnimated) {
|
|
769
|
+
if (this.instance)
|
|
770
|
+
return;
|
|
771
|
+
this.isSVG = xi(s), this.instance = s;
|
|
772
|
+
const { layoutId: a, layout: l, visualElement: h } = this.options;
|
|
773
|
+
if (h && !h.current && h.mount(s), this.root.nodes.add(this), this.parent && this.parent.children.add(this), n && (l || a) && (this.isLayoutDirty = !0), t) {
|
|
774
|
+
let c;
|
|
775
|
+
const d = () => this.root.updateBlockedByResize = !1;
|
|
776
|
+
t(s, () => {
|
|
777
|
+
this.root.updateBlockedByResize = !0, c && c(), c = vi(d, 250), _.hasAnimatedSinceResize && (_.hasAnimatedSinceResize = !1, this.nodes.forEach(Mt));
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
a && this.root.registerSharedNode(a, this), this.options.animate !== !1 && h && (a || l) && this.addEventListener("didUpdate", ({ delta: c, hasLayoutChanged: d, hasRelativeTargetChanged: m, layout: p }) => {
|
|
781
|
+
if (this.isTreeAnimationBlocked()) {
|
|
782
|
+
this.target = void 0, this.relativeTarget = void 0;
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const f = this.options.transition || h.getDefaultTransition() || Ui, { onLayoutAnimationStart: g, onLayoutAnimationComplete: x } = h.getProps(), L = !this.targetLayout || !se(this.targetLayout, p) || m, P = !d && m;
|
|
786
|
+
if (this.options.layoutRoot || this.resumeFrom && this.resumeFrom.instance || P || d && (L || !this.currentAnimation)) {
|
|
787
|
+
this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0), this.setAnimationOrigin(c, P);
|
|
788
|
+
const S = {
|
|
789
|
+
...Ae(f, "layout"),
|
|
790
|
+
onPlay: g,
|
|
791
|
+
onComplete: x
|
|
792
|
+
};
|
|
793
|
+
(h.shouldReduceMotion || this.options.layoutRoot) && (S.delay = 0, S.type = !1), this.startAnimation(S);
|
|
794
|
+
} else
|
|
795
|
+
d || Mt(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete();
|
|
796
|
+
this.targetLayout = p;
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
unmount() {
|
|
800
|
+
this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this);
|
|
801
|
+
const s = this.getStack();
|
|
802
|
+
s && s.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, O(this.updateProjection);
|
|
803
|
+
}
|
|
804
|
+
// only on the root
|
|
805
|
+
blockUpdate() {
|
|
806
|
+
this.updateManuallyBlocked = !0;
|
|
807
|
+
}
|
|
808
|
+
unblockUpdate() {
|
|
809
|
+
this.updateManuallyBlocked = !1;
|
|
810
|
+
}
|
|
811
|
+
isUpdateBlocked() {
|
|
812
|
+
return this.updateManuallyBlocked || this.updateBlockedByResize;
|
|
813
|
+
}
|
|
814
|
+
isTreeAnimationBlocked() {
|
|
815
|
+
return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1;
|
|
816
|
+
}
|
|
817
|
+
// Note: currently only running on root node
|
|
818
|
+
startUpdate() {
|
|
819
|
+
this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(Mi), this.animationId++);
|
|
820
|
+
}
|
|
821
|
+
getTransformTemplate() {
|
|
822
|
+
const { visualElement: s } = this.options;
|
|
823
|
+
return s && s.getProps().transformTemplate;
|
|
824
|
+
}
|
|
825
|
+
willUpdate(s = !0) {
|
|
826
|
+
if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) {
|
|
827
|
+
this.options.onExitComplete && this.options.onExitComplete();
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear && oe(this), !this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty)
|
|
831
|
+
return;
|
|
832
|
+
this.isLayoutDirty = !0;
|
|
833
|
+
for (let h = 0; h < this.path.length; h++) {
|
|
834
|
+
const c = this.path[h];
|
|
835
|
+
c.shouldResetTransform = !0, c.updateScroll("snapshot"), c.options.layoutRoot && c.willUpdate(!1);
|
|
836
|
+
}
|
|
837
|
+
const { layoutId: n, layout: a } = this.options;
|
|
838
|
+
if (n === void 0 && !a)
|
|
839
|
+
return;
|
|
840
|
+
const l = this.getTransformTemplate();
|
|
841
|
+
this.prevTransformTemplateValue = l ? l(this.latestValues, "") : void 0, this.updateSnapshot(), s && this.notifyListeners("willUpdate");
|
|
842
|
+
}
|
|
843
|
+
update() {
|
|
844
|
+
if (this.updateScheduled = !1, this.isUpdateBlocked()) {
|
|
845
|
+
this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(Bt);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
this.isUpdating || this.nodes.forEach(Ci), this.isUpdating = !1, this.nodes.forEach(ji), this.nodes.forEach(Si), this.nodes.forEach(Ei), this.clearAllSnapshots();
|
|
849
|
+
const n = Xt.now();
|
|
850
|
+
T.delta = Ot(0, 1e3 / 60, n - T.timestamp), T.timestamp = n, T.isProcessing = !0, $.update.process(T), $.preRender.process(T), $.render.process(T), T.isProcessing = !1;
|
|
851
|
+
}
|
|
852
|
+
didUpdate() {
|
|
853
|
+
this.updateScheduled || (this.updateScheduled = !0, Nt.read(this.scheduleUpdate));
|
|
854
|
+
}
|
|
855
|
+
clearAllSnapshots() {
|
|
856
|
+
this.nodes.forEach(Li), this.sharedNodes.forEach(wi);
|
|
857
|
+
}
|
|
858
|
+
scheduleUpdateProjection() {
|
|
859
|
+
this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, R.preRender(this.updateProjection, !1, !0));
|
|
860
|
+
}
|
|
861
|
+
scheduleCheckAfterUnmount() {
|
|
862
|
+
R.postRender(() => {
|
|
863
|
+
this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed();
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Update measurements
|
|
868
|
+
*/
|
|
869
|
+
updateSnapshot() {
|
|
870
|
+
this.snapshot || !this.instance || (this.snapshot = this.measure());
|
|
871
|
+
}
|
|
872
|
+
updateLayout() {
|
|
873
|
+
if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty))
|
|
874
|
+
return;
|
|
875
|
+
if (this.resumeFrom && !this.resumeFrom.instance)
|
|
876
|
+
for (let a = 0; a < this.path.length; a++)
|
|
877
|
+
this.path[a].updateScroll();
|
|
878
|
+
const s = this.layout;
|
|
879
|
+
this.layout = this.measure(!1), this.layoutCorrected = y(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox);
|
|
880
|
+
const { visualElement: n } = this.options;
|
|
881
|
+
n && n.notify("LayoutMeasure", this.layout.layoutBox, s ? s.layoutBox : void 0);
|
|
882
|
+
}
|
|
883
|
+
updateScroll(s = "measure") {
|
|
884
|
+
let n = !!(this.options.layoutScroll && this.instance);
|
|
885
|
+
if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === s && (n = !1), n) {
|
|
886
|
+
const a = o(this.instance);
|
|
887
|
+
this.scroll = {
|
|
888
|
+
animationId: this.root.animationId,
|
|
889
|
+
phase: s,
|
|
890
|
+
isRoot: a,
|
|
891
|
+
offset: i(this.instance),
|
|
892
|
+
wasRoot: this.scroll ? this.scroll.isRoot : a
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
resetTransform() {
|
|
897
|
+
if (!r)
|
|
898
|
+
return;
|
|
899
|
+
const s = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout, n = this.projectionDelta && !ie(this.projectionDelta), a = this.getTransformTemplate(), l = a ? a(this.latestValues, "") : void 0, h = l !== this.prevTransformTemplateValue;
|
|
900
|
+
s && (n || V(this.latestValues) || h) && (r(this.instance, l), this.shouldResetTransform = !1, this.scheduleRender());
|
|
901
|
+
}
|
|
902
|
+
measure(s = !0) {
|
|
903
|
+
const n = this.measurePageBox();
|
|
904
|
+
let a = this.removeElementScroll(n);
|
|
905
|
+
return s && (a = this.removeTransform(a)), Ii(a), {
|
|
906
|
+
animationId: this.root.animationId,
|
|
907
|
+
measuredBox: n,
|
|
908
|
+
layoutBox: a,
|
|
909
|
+
latestValues: {},
|
|
910
|
+
source: this.id
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
measurePageBox() {
|
|
914
|
+
var s;
|
|
915
|
+
const { visualElement: n } = this.options;
|
|
916
|
+
if (!n)
|
|
917
|
+
return y();
|
|
918
|
+
const a = n.measureViewportBox();
|
|
919
|
+
if (!(((s = this.scroll) === null || s === void 0 ? void 0 : s.wasRoot) || this.path.some(Oi))) {
|
|
920
|
+
const { scroll: h } = this.root;
|
|
921
|
+
h && (N(a.x, h.offset.x), N(a.y, h.offset.y));
|
|
922
|
+
}
|
|
923
|
+
return a;
|
|
924
|
+
}
|
|
925
|
+
removeElementScroll(s) {
|
|
926
|
+
var n;
|
|
927
|
+
const a = y();
|
|
928
|
+
if (E(a, s), !((n = this.scroll) === null || n === void 0) && n.wasRoot)
|
|
929
|
+
return a;
|
|
930
|
+
for (let l = 0; l < this.path.length; l++) {
|
|
931
|
+
const h = this.path[l], { scroll: c, options: d } = h;
|
|
932
|
+
h !== this.root && c && d.layoutScroll && (c.wasRoot && E(a, s), N(a.x, c.offset.x), N(a.y, c.offset.y));
|
|
933
|
+
}
|
|
934
|
+
return a;
|
|
935
|
+
}
|
|
936
|
+
applyTransform(s, n = !1) {
|
|
937
|
+
const a = y();
|
|
938
|
+
E(a, s);
|
|
939
|
+
for (let l = 0; l < this.path.length; l++) {
|
|
940
|
+
const h = this.path[l];
|
|
941
|
+
!n && h.options.layoutScroll && h.scroll && h !== h.root && G(a, {
|
|
942
|
+
x: -h.scroll.offset.x,
|
|
943
|
+
y: -h.scroll.offset.y
|
|
944
|
+
}), V(h.latestValues) && G(a, h.latestValues);
|
|
945
|
+
}
|
|
946
|
+
return V(this.latestValues) && G(a, this.latestValues), a;
|
|
947
|
+
}
|
|
948
|
+
removeTransform(s) {
|
|
949
|
+
const n = y();
|
|
950
|
+
E(n, s);
|
|
951
|
+
for (let a = 0; a < this.path.length; a++) {
|
|
952
|
+
const l = this.path[a];
|
|
953
|
+
if (!l.instance || !V(l.latestValues))
|
|
954
|
+
continue;
|
|
955
|
+
nt(l.latestValues) && l.updateSnapshot();
|
|
956
|
+
const h = y(), c = l.measurePageBox();
|
|
957
|
+
E(h, c), Et(n, l.latestValues, l.snapshot ? l.snapshot.layoutBox : void 0, h);
|
|
958
|
+
}
|
|
959
|
+
return V(this.latestValues) && Et(n, this.latestValues), n;
|
|
960
|
+
}
|
|
961
|
+
setTargetDelta(s) {
|
|
962
|
+
this.targetDelta = s, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0;
|
|
963
|
+
}
|
|
964
|
+
setOptions(s) {
|
|
965
|
+
this.options = {
|
|
966
|
+
...this.options,
|
|
967
|
+
...s,
|
|
968
|
+
crossfade: s.crossfade !== void 0 ? s.crossfade : !0
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
clearMeasurements() {
|
|
972
|
+
this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1;
|
|
973
|
+
}
|
|
974
|
+
forceRelativeParentToResolveTarget() {
|
|
975
|
+
this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== T.timestamp && this.relativeParent.resolveTargetDelta(!0);
|
|
976
|
+
}
|
|
977
|
+
resolveTargetDelta(s = !1) {
|
|
978
|
+
var n;
|
|
979
|
+
const a = this.getLead();
|
|
980
|
+
this.isProjectionDirty || (this.isProjectionDirty = a.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = a.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = a.isSharedProjectionDirty);
|
|
981
|
+
const l = !!this.resumingFrom || this !== a;
|
|
982
|
+
if (!(s || l && this.isSharedProjectionDirty || this.isProjectionDirty || !((n = this.parent) === null || n === void 0) && n.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize))
|
|
983
|
+
return;
|
|
984
|
+
const { layout: c, layoutId: d } = this.options;
|
|
985
|
+
if (!(!this.layout || !(c || d))) {
|
|
986
|
+
if (this.resolvedRelativeTargetAt = T.timestamp, !this.targetDelta && !this.relativeTarget) {
|
|
987
|
+
const m = this.getClosestProjectingParent();
|
|
988
|
+
m && m.layout && this.animationProgress !== 1 ? (this.relativeParent = m, this.forceRelativeParentToResolveTarget(), this.relativeTarget = y(), this.relativeTargetOrigin = y(), I(this.relativeTargetOrigin, this.layout.layoutBox, m.layout.layoutBox), E(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
|
|
989
|
+
}
|
|
990
|
+
if (!(!this.relativeTarget && !this.targetDelta)) {
|
|
991
|
+
if (this.target || (this.target = y(), this.targetWithTransforms = y()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), ze(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : E(this.target, this.layout.layoutBox), Re(this.target, this.targetDelta)) : E(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget) {
|
|
992
|
+
this.attemptToResolveRelativeTarget = !1;
|
|
993
|
+
const m = this.getClosestProjectingParent();
|
|
994
|
+
m && !!m.resumingFrom == !!this.resumingFrom && !m.options.layoutScroll && m.target && this.animationProgress !== 1 ? (this.relativeParent = m, this.forceRelativeParentToResolveTarget(), this.relativeTarget = y(), this.relativeTargetOrigin = y(), I(this.relativeTargetOrigin, this.target, m.target), E(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
|
|
995
|
+
}
|
|
996
|
+
k && C.resolvedTargetDeltas++;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
getClosestProjectingParent() {
|
|
1001
|
+
if (!(!this.parent || nt(this.parent.latestValues) || Le(this.parent.latestValues)))
|
|
1002
|
+
return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent();
|
|
1003
|
+
}
|
|
1004
|
+
isProjecting() {
|
|
1005
|
+
return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
|
|
1006
|
+
}
|
|
1007
|
+
calcProjection() {
|
|
1008
|
+
var s;
|
|
1009
|
+
const n = this.getLead(), a = !!this.resumingFrom || this !== n;
|
|
1010
|
+
let l = !0;
|
|
1011
|
+
if ((this.isProjectionDirty || !((s = this.parent) === null || s === void 0) && s.isProjectionDirty) && (l = !1), a && (this.isSharedProjectionDirty || this.isTransformDirty) && (l = !1), this.resolvedRelativeTargetAt === T.timestamp && (l = !1), l)
|
|
1012
|
+
return;
|
|
1013
|
+
const { layout: h, layoutId: c } = this.options;
|
|
1014
|
+
if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(h || c))
|
|
1015
|
+
return;
|
|
1016
|
+
E(this.layoutCorrected, this.layout.layoutBox);
|
|
1017
|
+
const d = this.treeScale.x, m = this.treeScale.y;
|
|
1018
|
+
Ce(this.layoutCorrected, this.treeScale, this.path, a), n.layout && !n.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (n.target = n.layout.layoutBox, n.targetWithTransforms = y());
|
|
1019
|
+
const { target: p } = n;
|
|
1020
|
+
if (!p) {
|
|
1021
|
+
this.prevProjectionDelta && (this.createProjectionDeltas(), this.scheduleRender());
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
!this.projectionDelta || !this.prevProjectionDelta ? this.createProjectionDeltas() : (Tt(this.prevProjectionDelta.x, this.projectionDelta.x), Tt(this.prevProjectionDelta.y, this.projectionDelta.y)), U(this.projectionDelta, this.layoutCorrected, p, this.latestValues), (this.treeScale.x !== d || this.treeScale.y !== m || !jt(this.projectionDelta.x, this.prevProjectionDelta.x) || !jt(this.projectionDelta.y, this.prevProjectionDelta.y)) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", p)), k && C.recalculatedProjection++;
|
|
1025
|
+
}
|
|
1026
|
+
hide() {
|
|
1027
|
+
this.isVisible = !1;
|
|
1028
|
+
}
|
|
1029
|
+
show() {
|
|
1030
|
+
this.isVisible = !0;
|
|
1031
|
+
}
|
|
1032
|
+
scheduleRender(s = !0) {
|
|
1033
|
+
var n;
|
|
1034
|
+
if ((n = this.options.visualElement) === null || n === void 0 || n.scheduleRender(), s) {
|
|
1035
|
+
const a = this.getStack();
|
|
1036
|
+
a && a.scheduleRender();
|
|
1037
|
+
}
|
|
1038
|
+
this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0);
|
|
1039
|
+
}
|
|
1040
|
+
createProjectionDeltas() {
|
|
1041
|
+
this.prevProjectionDelta = B(), this.projectionDelta = B(), this.projectionDeltaWithTransform = B();
|
|
1042
|
+
}
|
|
1043
|
+
setAnimationOrigin(s, n = !1) {
|
|
1044
|
+
const a = this.snapshot, l = a ? a.latestValues : {}, h = { ...this.latestValues }, c = B();
|
|
1045
|
+
(!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !n;
|
|
1046
|
+
const d = y(), m = a ? a.source : void 0, p = this.layout ? this.layout.source : void 0, f = m !== p, g = this.getStack(), x = !g || g.members.length <= 1, L = !!(f && !x && this.options.crossfade === !0 && !this.path.some(bi));
|
|
1047
|
+
this.animationProgress = 0;
|
|
1048
|
+
let P;
|
|
1049
|
+
this.mixTargetDelta = (S) => {
|
|
1050
|
+
const j = S / 1e3;
|
|
1051
|
+
wt(c.x, s.x, j), wt(c.y, s.y, j), this.setTargetDelta(c), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (I(d, this.layout.layoutBox, this.relativeParent.layout.layoutBox), ki(this.relativeTarget, this.relativeTargetOrigin, d, j), P && mi(this.relativeTarget, P) && (this.isProjectionDirty = !1), P || (P = y()), E(P, this.relativeTarget)), f && (this.animationValues = h, ri(h, l, this.latestValues, j, L, x)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = j;
|
|
1052
|
+
}, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
|
|
1053
|
+
}
|
|
1054
|
+
startAnimation(s) {
|
|
1055
|
+
this.notifyListeners("animationStart"), this.currentAnimation && this.currentAnimation.stop(), this.resumingFrom && this.resumingFrom.currentAnimation && this.resumingFrom.currentAnimation.stop(), this.pendingAnimation && (O(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = R.update(() => {
|
|
1056
|
+
_.hasAnimatedSinceResize = !0, this.currentAnimation = Pi(0, Vt, {
|
|
1057
|
+
...s,
|
|
1058
|
+
onUpdate: (n) => {
|
|
1059
|
+
this.mixTargetDelta(n), s.onUpdate && s.onUpdate(n);
|
|
1060
|
+
},
|
|
1061
|
+
onComplete: () => {
|
|
1062
|
+
s.onComplete && s.onComplete(), this.completeAnimation();
|
|
1063
|
+
}
|
|
1064
|
+
}), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0;
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
completeAnimation() {
|
|
1068
|
+
this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0);
|
|
1069
|
+
const s = this.getStack();
|
|
1070
|
+
s && s.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete");
|
|
1071
|
+
}
|
|
1072
|
+
finishAnimation() {
|
|
1073
|
+
this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(Vt), this.currentAnimation.stop()), this.completeAnimation();
|
|
1074
|
+
}
|
|
1075
|
+
applyTransformsToTarget() {
|
|
1076
|
+
const s = this.getLead();
|
|
1077
|
+
let { targetWithTransforms: n, target: a, layout: l, latestValues: h } = s;
|
|
1078
|
+
if (!(!n || !a || !l)) {
|
|
1079
|
+
if (this !== s && this.layout && l && ae(this.options.animationType, this.layout.layoutBox, l.layoutBox)) {
|
|
1080
|
+
a = this.target || y();
|
|
1081
|
+
const c = D(this.layout.layoutBox.x);
|
|
1082
|
+
a.x.min = s.target.x.min, a.x.max = a.x.min + c;
|
|
1083
|
+
const d = D(this.layout.layoutBox.y);
|
|
1084
|
+
a.y.min = s.target.y.min, a.y.max = a.y.min + d;
|
|
1085
|
+
}
|
|
1086
|
+
E(n, a), G(n, h), U(this.projectionDeltaWithTransform, this.layoutCorrected, n, h);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
registerSharedNode(s, n) {
|
|
1090
|
+
this.sharedNodes.has(s) || this.sharedNodes.set(s, new fi()), this.sharedNodes.get(s).add(n);
|
|
1091
|
+
const l = n.options.initialPromotionConfig;
|
|
1092
|
+
n.promote({
|
|
1093
|
+
transition: l ? l.transition : void 0,
|
|
1094
|
+
preserveFollowOpacity: l && l.shouldPreserveFollowOpacity ? l.shouldPreserveFollowOpacity(n) : void 0
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
isLead() {
|
|
1098
|
+
const s = this.getStack();
|
|
1099
|
+
return s ? s.lead === this : !0;
|
|
1100
|
+
}
|
|
1101
|
+
getLead() {
|
|
1102
|
+
var s;
|
|
1103
|
+
const { layoutId: n } = this.options;
|
|
1104
|
+
return n ? ((s = this.getStack()) === null || s === void 0 ? void 0 : s.lead) || this : this;
|
|
1105
|
+
}
|
|
1106
|
+
getPrevLead() {
|
|
1107
|
+
var s;
|
|
1108
|
+
const { layoutId: n } = this.options;
|
|
1109
|
+
return n ? (s = this.getStack()) === null || s === void 0 ? void 0 : s.prevLead : void 0;
|
|
1110
|
+
}
|
|
1111
|
+
getStack() {
|
|
1112
|
+
const { layoutId: s } = this.options;
|
|
1113
|
+
if (s)
|
|
1114
|
+
return this.root.sharedNodes.get(s);
|
|
1115
|
+
}
|
|
1116
|
+
promote({ needsReset: s, transition: n, preserveFollowOpacity: a } = {}) {
|
|
1117
|
+
const l = this.getStack();
|
|
1118
|
+
l && l.promote(this, a), s && (this.projectionDelta = void 0, this.needsReset = !0), n && this.setOptions({ transition: n });
|
|
1119
|
+
}
|
|
1120
|
+
relegate() {
|
|
1121
|
+
const s = this.getStack();
|
|
1122
|
+
return s ? s.relegate(this) : !1;
|
|
1123
|
+
}
|
|
1124
|
+
resetSkewAndRotation() {
|
|
1125
|
+
const { visualElement: s } = this.options;
|
|
1126
|
+
if (!s)
|
|
1127
|
+
return;
|
|
1128
|
+
let n = !1;
|
|
1129
|
+
const { latestValues: a } = s;
|
|
1130
|
+
if ((a.z || a.rotate || a.rotateX || a.rotateY || a.rotateZ || a.skewX || a.skewY) && (n = !0), !n)
|
|
1131
|
+
return;
|
|
1132
|
+
const l = {};
|
|
1133
|
+
a.z && Z("z", s, l, this.animationValues);
|
|
1134
|
+
for (let h = 0; h < q.length; h++)
|
|
1135
|
+
Z(`rotate${q[h]}`, s, l, this.animationValues), Z(`skew${q[h]}`, s, l, this.animationValues);
|
|
1136
|
+
s.render();
|
|
1137
|
+
for (const h in l)
|
|
1138
|
+
s.setStaticValue(h, l[h]), this.animationValues && (this.animationValues[h] = l[h]);
|
|
1139
|
+
s.scheduleRender();
|
|
1140
|
+
}
|
|
1141
|
+
getProjectionStyles(s) {
|
|
1142
|
+
var n, a;
|
|
1143
|
+
if (!this.instance || this.isSVG)
|
|
1144
|
+
return;
|
|
1145
|
+
if (!this.isVisible)
|
|
1146
|
+
return Ti;
|
|
1147
|
+
const l = {
|
|
1148
|
+
visibility: ""
|
|
1149
|
+
}, h = this.getTransformTemplate();
|
|
1150
|
+
if (this.needsReset)
|
|
1151
|
+
return this.needsReset = !1, l.opacity = "", l.pointerEvents = H(s?.pointerEvents) || "", l.transform = h ? h(this.latestValues, "") : "none", l;
|
|
1152
|
+
const c = this.getLead();
|
|
1153
|
+
if (!this.projectionDelta || !this.layout || !c.target) {
|
|
1154
|
+
const f = {};
|
|
1155
|
+
return this.options.layoutId && (f.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, f.pointerEvents = H(s?.pointerEvents) || ""), this.hasProjected && !V(this.latestValues) && (f.transform = h ? h({}, "") : "none", this.hasProjected = !1), f;
|
|
1156
|
+
}
|
|
1157
|
+
const d = c.animationValues || c.latestValues;
|
|
1158
|
+
this.applyTransformsToTarget(), l.transform = pi(this.projectionDeltaWithTransform, this.treeScale, d), h && (l.transform = h(d, l.transform));
|
|
1159
|
+
const { x: m, y: p } = this.projectionDelta;
|
|
1160
|
+
l.transformOrigin = `${m.origin * 100}% ${p.origin * 100}% 0`, c.animationValues ? l.opacity = c === this ? (a = (n = d.opacity) !== null && n !== void 0 ? n : this.latestValues.opacity) !== null && a !== void 0 ? a : 1 : this.preserveOpacity ? this.latestValues.opacity : d.opacityExit : l.opacity = c === this ? d.opacity !== void 0 ? d.opacity : "" : d.opacityExit !== void 0 ? d.opacityExit : 0;
|
|
1161
|
+
for (const f in et) {
|
|
1162
|
+
if (d[f] === void 0)
|
|
1163
|
+
continue;
|
|
1164
|
+
const { correct: g, applyTo: x } = et[f], L = l.transform === "none" ? d[f] : g(d[f], c);
|
|
1165
|
+
if (x) {
|
|
1166
|
+
const P = x.length;
|
|
1167
|
+
for (let S = 0; S < P; S++)
|
|
1168
|
+
l[x[S]] = L;
|
|
1169
|
+
} else
|
|
1170
|
+
l[f] = L;
|
|
1171
|
+
}
|
|
1172
|
+
return this.options.layoutId && (l.pointerEvents = c === this ? H(s?.pointerEvents) || "" : "none"), l;
|
|
1173
|
+
}
|
|
1174
|
+
clearSnapshot() {
|
|
1175
|
+
this.resumeFrom = this.snapshot = void 0;
|
|
1176
|
+
}
|
|
1177
|
+
// Only run on root
|
|
1178
|
+
resetTree() {
|
|
1179
|
+
this.root.nodes.forEach((s) => {
|
|
1180
|
+
var n;
|
|
1181
|
+
return (n = s.currentAnimation) === null || n === void 0 ? void 0 : n.stop();
|
|
1182
|
+
}), this.root.nodes.forEach(Bt), this.root.sharedNodes.clear();
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
function Si(t) {
|
|
1187
|
+
t.updateLayout();
|
|
1188
|
+
}
|
|
1189
|
+
function Ei(t) {
|
|
1190
|
+
var e;
|
|
1191
|
+
const i = ((e = t.resumeFrom) === null || e === void 0 ? void 0 : e.snapshot) || t.snapshot;
|
|
1192
|
+
if (t.isLead() && t.layout && i && t.hasListeners("didUpdate")) {
|
|
1193
|
+
const { layoutBox: o, measuredBox: r } = t.layout, { animationType: u } = t.options, s = i.source !== t.layout.source;
|
|
1194
|
+
u === "size" ? A((c) => {
|
|
1195
|
+
const d = s ? i.measuredBox[c] : i.layoutBox[c], m = D(d);
|
|
1196
|
+
d.min = o[c].min, d.max = d.min + m;
|
|
1197
|
+
}) : ae(u, i.layoutBox, o) && A((c) => {
|
|
1198
|
+
const d = s ? i.measuredBox[c] : i.layoutBox[c], m = D(o[c]);
|
|
1199
|
+
d.max = d.min + m, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[c].max = t.relativeTarget[c].min + m);
|
|
1200
|
+
});
|
|
1201
|
+
const n = B();
|
|
1202
|
+
U(n, o, i.layoutBox);
|
|
1203
|
+
const a = B();
|
|
1204
|
+
s ? U(a, t.applyTransform(r, !0), i.measuredBox) : U(a, o, i.layoutBox);
|
|
1205
|
+
const l = !ie(n);
|
|
1206
|
+
let h = !1;
|
|
1207
|
+
if (!t.resumeFrom) {
|
|
1208
|
+
const c = t.getClosestProjectingParent();
|
|
1209
|
+
if (c && !c.resumeFrom) {
|
|
1210
|
+
const { snapshot: d, layout: m } = c;
|
|
1211
|
+
if (d && m) {
|
|
1212
|
+
const p = y();
|
|
1213
|
+
I(p, i.layoutBox, d.layoutBox);
|
|
1214
|
+
const f = y();
|
|
1215
|
+
I(f, o, m.layoutBox), se(p, f) || (h = !0), c.options.layoutRoot && (t.relativeTarget = f, t.relativeTargetOrigin = p, t.relativeParent = c);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
t.notifyListeners("didUpdate", {
|
|
1220
|
+
layout: o,
|
|
1221
|
+
snapshot: i,
|
|
1222
|
+
delta: a,
|
|
1223
|
+
layoutDelta: n,
|
|
1224
|
+
hasLayoutChanged: l,
|
|
1225
|
+
hasRelativeTargetChanged: h
|
|
1226
|
+
});
|
|
1227
|
+
} else if (t.isLead()) {
|
|
1228
|
+
const { onExitComplete: o } = t.options;
|
|
1229
|
+
o && o();
|
|
1230
|
+
}
|
|
1231
|
+
t.options.transition = void 0;
|
|
1232
|
+
}
|
|
1233
|
+
function Ai(t) {
|
|
1234
|
+
k && C.totalNodes++, t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty));
|
|
1235
|
+
}
|
|
1236
|
+
function Ri(t) {
|
|
1237
|
+
t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1;
|
|
1238
|
+
}
|
|
1239
|
+
function Li(t) {
|
|
1240
|
+
t.clearSnapshot();
|
|
1241
|
+
}
|
|
1242
|
+
function Bt(t) {
|
|
1243
|
+
t.clearMeasurements();
|
|
1244
|
+
}
|
|
1245
|
+
function Ci(t) {
|
|
1246
|
+
t.isLayoutDirty = !1;
|
|
1247
|
+
}
|
|
1248
|
+
function ji(t) {
|
|
1249
|
+
const { visualElement: e } = t.options;
|
|
1250
|
+
e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform();
|
|
1251
|
+
}
|
|
1252
|
+
function Mt(t) {
|
|
1253
|
+
t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0;
|
|
1254
|
+
}
|
|
1255
|
+
function Vi(t) {
|
|
1256
|
+
t.resolveTargetDelta();
|
|
1257
|
+
}
|
|
1258
|
+
function Bi(t) {
|
|
1259
|
+
t.calcProjection();
|
|
1260
|
+
}
|
|
1261
|
+
function Mi(t) {
|
|
1262
|
+
t.resetSkewAndRotation();
|
|
1263
|
+
}
|
|
1264
|
+
function wi(t) {
|
|
1265
|
+
t.removeLeadSnapshot();
|
|
1266
|
+
}
|
|
1267
|
+
function wt(t, e, i) {
|
|
1268
|
+
t.translate = v(e.translate, 0, i), t.scale = v(e.scale, 1, i), t.origin = e.origin, t.originPoint = e.originPoint;
|
|
1269
|
+
}
|
|
1270
|
+
function kt(t, e, i, o) {
|
|
1271
|
+
t.min = v(e.min, i.min, o), t.max = v(e.max, i.max, o);
|
|
1272
|
+
}
|
|
1273
|
+
function ki(t, e, i, o) {
|
|
1274
|
+
kt(t.x, e.x, i.x, o), kt(t.y, e.y, i.y, o);
|
|
1275
|
+
}
|
|
1276
|
+
function bi(t) {
|
|
1277
|
+
return t.animationValues && t.animationValues.opacityExit !== void 0;
|
|
1278
|
+
}
|
|
1279
|
+
const Ui = {
|
|
1280
|
+
duration: 0.45,
|
|
1281
|
+
ease: [0.4, 0, 0.1, 1]
|
|
1282
|
+
}, bt = (t) => typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(t), Ut = bt("applewebkit/") && !bt("chrome/") ? Math.round : M;
|
|
1283
|
+
function It(t) {
|
|
1284
|
+
t.min = Ut(t.min), t.max = Ut(t.max);
|
|
1285
|
+
}
|
|
1286
|
+
function Ii(t) {
|
|
1287
|
+
It(t.x), It(t.y);
|
|
1288
|
+
}
|
|
1289
|
+
function ae(t, e, i) {
|
|
1290
|
+
return t === "position" || t === "preserve-aspect" && !_e(Ct(e), Ct(i), 0.2);
|
|
1291
|
+
}
|
|
1292
|
+
function Oi(t) {
|
|
1293
|
+
var e;
|
|
1294
|
+
return t !== t.root && ((e = t.scroll) === null || e === void 0 ? void 0 : e.wasRoot);
|
|
1295
|
+
}
|
|
1296
|
+
const Fi = ne({
|
|
1297
|
+
attachResizeListener: (t, e) => $t(t, "resize", e),
|
|
1298
|
+
measureScroll: () => ({
|
|
1299
|
+
x: document.documentElement.scrollLeft || document.body.scrollLeft,
|
|
1300
|
+
y: document.documentElement.scrollTop || document.body.scrollTop
|
|
1301
|
+
}),
|
|
1302
|
+
checkIsScrollRoot: () => !0
|
|
1303
|
+
}), K = {
|
|
1304
|
+
current: void 0
|
|
1305
|
+
}, re = ne({
|
|
1306
|
+
measureScroll: (t) => ({
|
|
1307
|
+
x: t.scrollLeft,
|
|
1308
|
+
y: t.scrollTop
|
|
1309
|
+
}),
|
|
1310
|
+
defaultParent: () => {
|
|
1311
|
+
if (!K.current) {
|
|
1312
|
+
const t = new Fi({});
|
|
1313
|
+
t.mount(window), t.setOptions({ layoutScroll: !0 }), K.current = t;
|
|
1314
|
+
}
|
|
1315
|
+
return K.current;
|
|
1316
|
+
},
|
|
1317
|
+
resetTransform: (t, e) => {
|
|
1318
|
+
t.style.transform = e !== void 0 ? e : "none";
|
|
1319
|
+
},
|
|
1320
|
+
checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed"
|
|
1321
|
+
}), Ni = {
|
|
1322
|
+
pan: {
|
|
1323
|
+
Feature: ei
|
|
1324
|
+
},
|
|
1325
|
+
drag: {
|
|
1326
|
+
Feature: ti,
|
|
1327
|
+
ProjectionNode: re,
|
|
1328
|
+
MeasureLayout: Qt
|
|
1329
|
+
}
|
|
1330
|
+
}, Gi = {
|
|
1331
|
+
layout: {
|
|
1332
|
+
ProjectionNode: re,
|
|
1333
|
+
MeasureLayout: Qt
|
|
1334
|
+
}
|
|
1335
|
+
}, Xi = {
|
|
1336
|
+
...Ve,
|
|
1337
|
+
...Ni,
|
|
1338
|
+
...Gi
|
|
1339
|
+
};
|
|
1340
|
+
export {
|
|
1341
|
+
ms as AcceleratedAnimation,
|
|
1342
|
+
Zi as AnimatePresence,
|
|
1343
|
+
yi as FlatTree,
|
|
1344
|
+
ce as LayoutGroupContext,
|
|
1345
|
+
Ki as LazyMotion,
|
|
1346
|
+
Ji as MotionConfig,
|
|
1347
|
+
Qi as MotionConfigContext,
|
|
1348
|
+
ts as MotionContext,
|
|
1349
|
+
es as MotionGlobalConfig,
|
|
1350
|
+
fs as MotionValue,
|
|
1351
|
+
he as PresenceContext,
|
|
1352
|
+
ue as SwitchLayoutGroupContext,
|
|
1353
|
+
ps as VisualElement,
|
|
1354
|
+
b as addPointerEvent,
|
|
1355
|
+
gs as addPointerInfo,
|
|
1356
|
+
de as addScaleCorrector,
|
|
1357
|
+
ys as animateVisualElement,
|
|
1358
|
+
vs as animations,
|
|
1359
|
+
xs as anticipate,
|
|
1360
|
+
Ps as backIn,
|
|
1361
|
+
Ts as backInOut,
|
|
1362
|
+
Ds as backOut,
|
|
1363
|
+
is as buildTransform,
|
|
1364
|
+
D as calcLength,
|
|
1365
|
+
O as cancelFrame,
|
|
1366
|
+
Ss as circIn,
|
|
1367
|
+
Es as circInOut,
|
|
1368
|
+
De as circOut,
|
|
1369
|
+
Ot as clamp,
|
|
1370
|
+
As as color,
|
|
1371
|
+
st as complex,
|
|
1372
|
+
y as createBox,
|
|
1373
|
+
ss as createRendererMotionComponent,
|
|
1374
|
+
Rs as cubicBezier,
|
|
1375
|
+
vi as delay,
|
|
1376
|
+
at as distance,
|
|
1377
|
+
Ue as distance2D,
|
|
1378
|
+
Ve as domAnimation,
|
|
1379
|
+
Xi as domMax,
|
|
1380
|
+
Ls as easeIn,
|
|
1381
|
+
Cs as easeInOut,
|
|
1382
|
+
js as easeOut,
|
|
1383
|
+
os as filterProps,
|
|
1384
|
+
Vs as findSpring,
|
|
1385
|
+
R as frame,
|
|
1386
|
+
T as frameData,
|
|
1387
|
+
Bs as interpolate,
|
|
1388
|
+
le as invariant,
|
|
1389
|
+
ns as isBrowser,
|
|
1390
|
+
Ms as isDragActive,
|
|
1391
|
+
me as isMotionValue,
|
|
1392
|
+
as as isValidMotionProp,
|
|
1393
|
+
rs as m,
|
|
1394
|
+
ls as makeUseVisualState,
|
|
1395
|
+
ws as mirrorEasing,
|
|
1396
|
+
ks as mix,
|
|
1397
|
+
Se as motionValue,
|
|
1398
|
+
hs as optimizedAppearDataAttribute,
|
|
1399
|
+
pe as pipe,
|
|
1400
|
+
J as progress,
|
|
1401
|
+
Ft as px,
|
|
1402
|
+
H as resolveMotionValue,
|
|
1403
|
+
bs as reverseEasing,
|
|
1404
|
+
Us as spring,
|
|
1405
|
+
$ as steps,
|
|
1406
|
+
cs as useIsomorphicLayoutEffect,
|
|
1407
|
+
ii as usePresence,
|
|
1408
|
+
Is as visualElementStore,
|
|
1409
|
+
us as warning
|
|
1410
|
+
};
|