locusing 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-43J4IVK3.mjs +597 -0
- package/dist/chunk-Y4M467JV.mjs +607 -0
- package/dist/index.d.mts +4505 -54
- package/dist/index.d.ts +4505 -54
- package/dist/index.js +6972 -259
- package/dist/index.mjs +6564 -220
- package/dist/transform-7YKZIQ3I.mjs +22 -0
- package/dist/transform-KYXVRPBM.mjs +22 -0
- package/package.json +32 -9
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/animate/animations/transform.ts
|
|
34
|
+
import { gsap as gsap2 } from "gsap";
|
|
35
|
+
|
|
36
|
+
// src/animate/timeline.ts
|
|
37
|
+
import { gsap } from "gsap";
|
|
38
|
+
var Timeline = class {
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
this._status = "pending";
|
|
41
|
+
this.timeline = gsap.timeline({
|
|
42
|
+
paused: true,
|
|
43
|
+
onStart: () => {
|
|
44
|
+
var _a;
|
|
45
|
+
this._status = "running";
|
|
46
|
+
(_a = options.onStart) == null ? void 0 : _a.call(options);
|
|
47
|
+
},
|
|
48
|
+
onComplete: () => {
|
|
49
|
+
var _a;
|
|
50
|
+
this._status = "completed";
|
|
51
|
+
(_a = options.onComplete) == null ? void 0 : _a.call(options);
|
|
52
|
+
},
|
|
53
|
+
onUpdate: () => {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = options.onUpdate) == null ? void 0 : _a.call(options, this.progress);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** 当前状态 */
|
|
60
|
+
get status() {
|
|
61
|
+
return this._status;
|
|
62
|
+
}
|
|
63
|
+
/** 当前进度 (0-1) */
|
|
64
|
+
get progress() {
|
|
65
|
+
return this.timeline.progress();
|
|
66
|
+
}
|
|
67
|
+
/** 总时长 */
|
|
68
|
+
get duration() {
|
|
69
|
+
return this.timeline.duration();
|
|
70
|
+
}
|
|
71
|
+
/** 当前时间 */
|
|
72
|
+
get time() {
|
|
73
|
+
return this.timeline.time();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 添加动画到时间线
|
|
77
|
+
*/
|
|
78
|
+
add(target, vars, position) {
|
|
79
|
+
this.timeline.to(target, vars, position);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 添加回调函数
|
|
84
|
+
*/
|
|
85
|
+
call(callback, position) {
|
|
86
|
+
this.timeline.call(callback, void 0, position);
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 添加延迟
|
|
91
|
+
*/
|
|
92
|
+
delay(seconds, position) {
|
|
93
|
+
this.timeline.to({}, { duration: seconds }, position);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 添加标签
|
|
98
|
+
*/
|
|
99
|
+
label(name, position) {
|
|
100
|
+
this.timeline.addLabel(name, position);
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 播放
|
|
105
|
+
*/
|
|
106
|
+
play() {
|
|
107
|
+
this._status = "running";
|
|
108
|
+
this.timeline.play();
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 暂停
|
|
113
|
+
*/
|
|
114
|
+
pause() {
|
|
115
|
+
this._status = "paused";
|
|
116
|
+
this.timeline.pause();
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 恢复
|
|
121
|
+
*/
|
|
122
|
+
resume() {
|
|
123
|
+
this._status = "running";
|
|
124
|
+
this.timeline.resume();
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 停止并重置
|
|
129
|
+
*/
|
|
130
|
+
restart() {
|
|
131
|
+
this._status = "pending";
|
|
132
|
+
this.timeline.restart();
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 跳转到指定时间
|
|
137
|
+
*/
|
|
138
|
+
seek(time) {
|
|
139
|
+
this.timeline.seek(time);
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 设置进度
|
|
144
|
+
*/
|
|
145
|
+
setProgress(progress) {
|
|
146
|
+
this.timeline.progress(progress);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 设置速度
|
|
151
|
+
*/
|
|
152
|
+
setSpeed(speed) {
|
|
153
|
+
this.timeline.timeScale(speed);
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 反向播放
|
|
158
|
+
*/
|
|
159
|
+
reverse() {
|
|
160
|
+
this.timeline.reverse();
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 销毁
|
|
165
|
+
*/
|
|
166
|
+
kill() {
|
|
167
|
+
this.timeline.kill();
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 等待完成
|
|
171
|
+
*/
|
|
172
|
+
async finished() {
|
|
173
|
+
return new Promise((resolve) => {
|
|
174
|
+
this.timeline.eventCallback("onComplete", resolve);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function createTimeline(options) {
|
|
179
|
+
return new Timeline(options);
|
|
180
|
+
}
|
|
181
|
+
var easingMap = {
|
|
182
|
+
linear: "none",
|
|
183
|
+
easeIn: "power2.in",
|
|
184
|
+
easeOut: "power2.out",
|
|
185
|
+
easeInOut: "power2.inOut",
|
|
186
|
+
easeInQuad: "power1.in",
|
|
187
|
+
easeOutQuad: "power1.out",
|
|
188
|
+
easeInOutQuad: "power1.inOut",
|
|
189
|
+
easeInCubic: "power2.in",
|
|
190
|
+
easeOutCubic: "power2.out",
|
|
191
|
+
easeInOutCubic: "power2.inOut",
|
|
192
|
+
easeInQuart: "power3.in",
|
|
193
|
+
easeOutQuart: "power3.out",
|
|
194
|
+
easeInOutQuart: "power3.inOut",
|
|
195
|
+
easeInQuint: "power4.in",
|
|
196
|
+
easeOutQuint: "power4.out",
|
|
197
|
+
easeInOutQuint: "power4.inOut",
|
|
198
|
+
easeInSine: "sine.in",
|
|
199
|
+
easeOutSine: "sine.out",
|
|
200
|
+
easeInOutSine: "sine.inOut",
|
|
201
|
+
easeInExpo: "expo.in",
|
|
202
|
+
easeOutExpo: "expo.out",
|
|
203
|
+
easeInOutExpo: "expo.inOut",
|
|
204
|
+
easeInCirc: "circ.in",
|
|
205
|
+
easeOutCirc: "circ.out",
|
|
206
|
+
easeInOutCirc: "circ.inOut",
|
|
207
|
+
easeInBack: "back.in",
|
|
208
|
+
easeOutBack: "back.out",
|
|
209
|
+
easeInOutBack: "back.inOut",
|
|
210
|
+
easeInElastic: "elastic.in",
|
|
211
|
+
easeOutElastic: "elastic.out",
|
|
212
|
+
easeInOutElastic: "elastic.inOut",
|
|
213
|
+
easeInBounce: "bounce.in",
|
|
214
|
+
easeOutBounce: "bounce.out",
|
|
215
|
+
easeInOutBounce: "bounce.inOut"
|
|
216
|
+
};
|
|
217
|
+
function getGSAPEasing(easing) {
|
|
218
|
+
return easingMap[easing] || easing;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// src/animate/animations/utils.ts
|
|
222
|
+
function querySelectorAllIncludingSelf(element, selector) {
|
|
223
|
+
const results = Array.from(element.querySelectorAll(selector));
|
|
224
|
+
if (element.matches(selector)) {
|
|
225
|
+
results.unshift(element);
|
|
226
|
+
}
|
|
227
|
+
return results;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/animate/animations/transform.ts
|
|
231
|
+
function Transform(source, target, options = {}) {
|
|
232
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
233
|
+
return {
|
|
234
|
+
duration,
|
|
235
|
+
target: source,
|
|
236
|
+
execute(scene, timeline, startTime) {
|
|
237
|
+
var _a, _b;
|
|
238
|
+
const sourceElement = scene.getElement(source);
|
|
239
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
240
|
+
if (!sourceElement || !targetElement) return;
|
|
241
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
242
|
+
const sourceBBox = ((_a = sourceElement.getBBox) == null ? void 0 : _a.call(sourceElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
243
|
+
const targetBBox = ((_b = targetElement.getBBox) == null ? void 0 : _b.call(targetElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
244
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
245
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
246
|
+
const translateX = targetBBox.x + targetBBox.width / 2 - (sourceBBox.x + sourceBBox.width / 2);
|
|
247
|
+
const translateY = targetBBox.y + targetBBox.height / 2 - (sourceBBox.y + sourceBBox.height / 2);
|
|
248
|
+
const originX = sourceBBox.x + sourceBBox.width / 2;
|
|
249
|
+
const originY = sourceBBox.y + sourceBBox.height / 2;
|
|
250
|
+
gsap2.set(sourceElement, {
|
|
251
|
+
transformOrigin: `${originX}px ${originY}px`
|
|
252
|
+
});
|
|
253
|
+
timeline.add(sourceElement, {
|
|
254
|
+
scaleX,
|
|
255
|
+
scaleY,
|
|
256
|
+
x: translateX,
|
|
257
|
+
y: translateY,
|
|
258
|
+
duration,
|
|
259
|
+
ease: getGSAPEasing(easing),
|
|
260
|
+
delay,
|
|
261
|
+
onComplete: () => {
|
|
262
|
+
sourceElement.remove();
|
|
263
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
264
|
+
}
|
|
265
|
+
}, startTime);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function ReplacementTransform(source, target, options = {}) {
|
|
270
|
+
const { duration = 1, easing = "easeInOut", delay = 0, replace = true } = options;
|
|
271
|
+
return {
|
|
272
|
+
duration,
|
|
273
|
+
target: source,
|
|
274
|
+
execute(scene, timeline, startTime) {
|
|
275
|
+
var _a, _b;
|
|
276
|
+
const sourceElement = scene.getElement(source);
|
|
277
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
278
|
+
if (!sourceElement || !targetElement) return;
|
|
279
|
+
gsap2.set(targetElement, { opacity: 0, visibility: "hidden" });
|
|
280
|
+
const sourceBBox = ((_a = sourceElement.getBBox) == null ? void 0 : _a.call(sourceElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
281
|
+
const targetBBox = ((_b = targetElement.getBBox) == null ? void 0 : _b.call(targetElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
282
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
283
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
284
|
+
const sourceCenterX = sourceBBox.x + sourceBBox.width / 2;
|
|
285
|
+
const sourceCenterY = sourceBBox.y + sourceBBox.height / 2;
|
|
286
|
+
const targetCenterX = targetBBox.x + targetBBox.width / 2;
|
|
287
|
+
const targetCenterY = targetBBox.y + targetBBox.height / 2;
|
|
288
|
+
timeline.add(sourceElement, {
|
|
289
|
+
transformOrigin: `${sourceCenterX}px ${sourceCenterY}px`,
|
|
290
|
+
scaleX,
|
|
291
|
+
scaleY,
|
|
292
|
+
x: targetCenterX - sourceCenterX,
|
|
293
|
+
y: targetCenterY - sourceCenterY,
|
|
294
|
+
opacity: 0,
|
|
295
|
+
duration,
|
|
296
|
+
ease: getGSAPEasing(easing),
|
|
297
|
+
delay,
|
|
298
|
+
onComplete: () => {
|
|
299
|
+
if (replace) {
|
|
300
|
+
sourceElement.remove();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}, startTime);
|
|
304
|
+
timeline.add(targetElement, {
|
|
305
|
+
visibility: "visible",
|
|
306
|
+
opacity: 1,
|
|
307
|
+
duration: duration * 0.5,
|
|
308
|
+
ease: "power2.out",
|
|
309
|
+
delay: delay + duration * 0.5
|
|
310
|
+
}, startTime);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function MoveToTarget(target, options = {}) {
|
|
315
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
316
|
+
return {
|
|
317
|
+
duration,
|
|
318
|
+
target,
|
|
319
|
+
execute(scene, timeline, startTime) {
|
|
320
|
+
const element = scene.getElement(target);
|
|
321
|
+
if (!element) return;
|
|
322
|
+
const targetState = target._targetState;
|
|
323
|
+
if (targetState) {
|
|
324
|
+
timeline.add(element, __spreadProps(__spreadValues({}, targetState), {
|
|
325
|
+
duration,
|
|
326
|
+
ease: getGSAPEasing(easing),
|
|
327
|
+
delay
|
|
328
|
+
}), startTime);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function Morphing(source, target, options = {}) {
|
|
334
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
335
|
+
return {
|
|
336
|
+
duration,
|
|
337
|
+
target: source,
|
|
338
|
+
execute(scene, timeline, startTime) {
|
|
339
|
+
var _a;
|
|
340
|
+
const sourceElement = scene.getElement(source);
|
|
341
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
342
|
+
if (!sourceElement || !targetElement) return;
|
|
343
|
+
const sourcePath = sourceElement.querySelector("path") || sourceElement;
|
|
344
|
+
const targetPath = targetElement.querySelector("path") || targetElement;
|
|
345
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
346
|
+
if ((_a = gsap2.plugins) == null ? void 0 : _a.morphSVG) {
|
|
347
|
+
const targetD = targetPath.getAttribute("d");
|
|
348
|
+
if (targetD) {
|
|
349
|
+
timeline.add(sourcePath, {
|
|
350
|
+
morphSVG: targetD,
|
|
351
|
+
duration,
|
|
352
|
+
ease: getGSAPEasing(easing),
|
|
353
|
+
delay,
|
|
354
|
+
onComplete: () => {
|
|
355
|
+
sourceElement.remove();
|
|
356
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
357
|
+
}
|
|
358
|
+
}, startTime);
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
Transform(source, target, options).execute(scene, timeline, startTime);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function TransformMatchingShapes(source, target, options = {}) {
|
|
367
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
368
|
+
return {
|
|
369
|
+
duration,
|
|
370
|
+
target: source,
|
|
371
|
+
execute(scene, timeline, startTime) {
|
|
372
|
+
var _a, _b;
|
|
373
|
+
const sourceElement = scene.getElement(source);
|
|
374
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
375
|
+
if (!sourceElement || !targetElement) return;
|
|
376
|
+
const sourceChildren = Array.from(sourceElement.children);
|
|
377
|
+
const targetChildren = Array.from(targetElement.children);
|
|
378
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
379
|
+
const pairs = Math.min(sourceChildren.length, targetChildren.length);
|
|
380
|
+
for (let i = 0; i < pairs; i++) {
|
|
381
|
+
const sourceChild = sourceChildren[i];
|
|
382
|
+
const targetChild = targetChildren[i];
|
|
383
|
+
const sourceBBox = ((_a = sourceChild.getBBox) == null ? void 0 : _a.call(sourceChild)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
384
|
+
const targetBBox = ((_b = targetChild.getBBox) == null ? void 0 : _b.call(targetChild)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
385
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
386
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
387
|
+
const translateX = targetBBox.x - sourceBBox.x;
|
|
388
|
+
const translateY = targetBBox.y - sourceBBox.y;
|
|
389
|
+
timeline.add(sourceChild, {
|
|
390
|
+
scaleX,
|
|
391
|
+
scaleY,
|
|
392
|
+
x: translateX,
|
|
393
|
+
y: translateY,
|
|
394
|
+
duration,
|
|
395
|
+
ease: getGSAPEasing(easing),
|
|
396
|
+
delay
|
|
397
|
+
}, startTime);
|
|
398
|
+
}
|
|
399
|
+
for (let i = pairs; i < sourceChildren.length; i++) {
|
|
400
|
+
const child = sourceChildren[i];
|
|
401
|
+
if (child) {
|
|
402
|
+
timeline.add(child, {
|
|
403
|
+
opacity: 0,
|
|
404
|
+
duration: duration * 0.5,
|
|
405
|
+
ease: "power2.in"
|
|
406
|
+
}, startTime);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
timeline.call(() => {
|
|
410
|
+
sourceElement.remove();
|
|
411
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
412
|
+
}, startTime + duration);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function TransformMatchingTex(source, target, options = {}) {
|
|
417
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
418
|
+
return {
|
|
419
|
+
duration,
|
|
420
|
+
target: source,
|
|
421
|
+
execute(scene, timeline, startTime) {
|
|
422
|
+
var _a, _b;
|
|
423
|
+
const sourceElement = scene.getElement(source);
|
|
424
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
425
|
+
if (!sourceElement || !targetElement) return;
|
|
426
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
427
|
+
const sourceTexParts = querySelectorAllIncludingSelf(sourceElement, "path, use, text");
|
|
428
|
+
const targetTexParts = querySelectorAllIncludingSelf(targetElement, "path, use, text");
|
|
429
|
+
const pairs = Math.min(sourceTexParts.length, targetTexParts.length);
|
|
430
|
+
for (let i = 0; i < pairs; i++) {
|
|
431
|
+
const sourcePart = sourceTexParts[i];
|
|
432
|
+
const targetPart = targetTexParts[i];
|
|
433
|
+
const sourceBBox = ((_a = sourcePart.getBBox) == null ? void 0 : _a.call(sourcePart)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
434
|
+
const targetBBox = ((_b = targetPart.getBBox) == null ? void 0 : _b.call(targetPart)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
435
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
436
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
437
|
+
const translateX = targetBBox.x + targetBBox.width / 2 - (sourceBBox.x + sourceBBox.width / 2);
|
|
438
|
+
const translateY = targetBBox.y + targetBBox.height / 2 - (sourceBBox.y + sourceBBox.height / 2);
|
|
439
|
+
timeline.add(sourcePart, {
|
|
440
|
+
scaleX: isFinite(scaleX) ? scaleX : 1,
|
|
441
|
+
scaleY: isFinite(scaleY) ? scaleY : 1,
|
|
442
|
+
x: translateX,
|
|
443
|
+
y: translateY,
|
|
444
|
+
duration,
|
|
445
|
+
ease: getGSAPEasing(easing),
|
|
446
|
+
delay
|
|
447
|
+
}, startTime);
|
|
448
|
+
}
|
|
449
|
+
for (let i = pairs; i < sourceTexParts.length; i++) {
|
|
450
|
+
const part = sourceTexParts[i];
|
|
451
|
+
if (part) {
|
|
452
|
+
timeline.add(part, {
|
|
453
|
+
opacity: 0,
|
|
454
|
+
duration: duration * 0.5,
|
|
455
|
+
ease: "power2.in"
|
|
456
|
+
}, startTime);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
timeline.call(() => {
|
|
460
|
+
sourceElement.remove();
|
|
461
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
462
|
+
}, startTime + duration);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
function ClockwiseTransform(source, target, options = {}) {
|
|
467
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
468
|
+
return {
|
|
469
|
+
duration,
|
|
470
|
+
target: source,
|
|
471
|
+
execute(scene, timeline, startTime) {
|
|
472
|
+
var _a, _b;
|
|
473
|
+
const sourceElement = scene.getElement(source);
|
|
474
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
475
|
+
if (!sourceElement || !targetElement) return;
|
|
476
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
477
|
+
const sourceBBox = ((_a = sourceElement.getBBox) == null ? void 0 : _a.call(sourceElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
478
|
+
const targetBBox = ((_b = targetElement.getBBox) == null ? void 0 : _b.call(targetElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
479
|
+
const sourceCenterX = sourceBBox.x + sourceBBox.width / 2;
|
|
480
|
+
const sourceCenterY = sourceBBox.y + sourceBBox.height / 2;
|
|
481
|
+
const targetCenterX = targetBBox.x + targetBBox.width / 2;
|
|
482
|
+
const targetCenterY = targetBBox.y + targetBBox.height / 2;
|
|
483
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
484
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
485
|
+
gsap2.set(sourceElement, {
|
|
486
|
+
transformOrigin: `${sourceCenterX}px ${sourceCenterY}px`
|
|
487
|
+
});
|
|
488
|
+
timeline.add(sourceElement, {
|
|
489
|
+
rotation: 180,
|
|
490
|
+
scaleX: isFinite(scaleX) ? scaleX : 1,
|
|
491
|
+
scaleY: isFinite(scaleY) ? scaleY : 1,
|
|
492
|
+
x: targetCenterX - sourceCenterX,
|
|
493
|
+
y: targetCenterY - sourceCenterY,
|
|
494
|
+
opacity: 0,
|
|
495
|
+
duration,
|
|
496
|
+
ease: getGSAPEasing(easing),
|
|
497
|
+
delay,
|
|
498
|
+
onComplete: () => {
|
|
499
|
+
sourceElement.remove();
|
|
500
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
501
|
+
}
|
|
502
|
+
}, startTime);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function CounterclockwiseTransform(source, target, options = {}) {
|
|
507
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
508
|
+
return {
|
|
509
|
+
duration,
|
|
510
|
+
target: source,
|
|
511
|
+
execute(scene, timeline, startTime) {
|
|
512
|
+
var _a, _b;
|
|
513
|
+
const sourceElement = scene.getElement(source);
|
|
514
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
515
|
+
if (!sourceElement || !targetElement) return;
|
|
516
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
517
|
+
const sourceBBox = ((_a = sourceElement.getBBox) == null ? void 0 : _a.call(sourceElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
518
|
+
const targetBBox = ((_b = targetElement.getBBox) == null ? void 0 : _b.call(targetElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
519
|
+
const sourceCenterX = sourceBBox.x + sourceBBox.width / 2;
|
|
520
|
+
const sourceCenterY = sourceBBox.y + sourceBBox.height / 2;
|
|
521
|
+
const targetCenterX = targetBBox.x + targetBBox.width / 2;
|
|
522
|
+
const targetCenterY = targetBBox.y + targetBBox.height / 2;
|
|
523
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
524
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
525
|
+
gsap2.set(sourceElement, {
|
|
526
|
+
transformOrigin: `${sourceCenterX}px ${sourceCenterY}px`
|
|
527
|
+
});
|
|
528
|
+
timeline.add(sourceElement, {
|
|
529
|
+
rotation: -180,
|
|
530
|
+
scaleX: isFinite(scaleX) ? scaleX : 1,
|
|
531
|
+
scaleY: isFinite(scaleY) ? scaleY : 1,
|
|
532
|
+
x: targetCenterX - sourceCenterX,
|
|
533
|
+
y: targetCenterY - sourceCenterY,
|
|
534
|
+
opacity: 0,
|
|
535
|
+
duration,
|
|
536
|
+
ease: getGSAPEasing(easing),
|
|
537
|
+
delay,
|
|
538
|
+
onComplete: () => {
|
|
539
|
+
sourceElement.remove();
|
|
540
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
541
|
+
}
|
|
542
|
+
}, startTime);
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function TransformFromCopy(source, target, options = {}) {
|
|
547
|
+
const { duration = 1, easing = "easeInOut", delay = 0 } = options;
|
|
548
|
+
return {
|
|
549
|
+
duration,
|
|
550
|
+
target: source,
|
|
551
|
+
execute(scene, timeline, startTime) {
|
|
552
|
+
var _a, _b, _c;
|
|
553
|
+
const sourceElement = scene.getElement(source);
|
|
554
|
+
const targetElement = scene.getOrCreateElement(target);
|
|
555
|
+
if (!sourceElement || !targetElement) return;
|
|
556
|
+
gsap2.set(targetElement, { opacity: 0 });
|
|
557
|
+
const copyElement = sourceElement.cloneNode(true);
|
|
558
|
+
copyElement.setAttribute("id", `${sourceElement.id}-copy-${Date.now()}`);
|
|
559
|
+
(_a = sourceElement.parentNode) == null ? void 0 : _a.appendChild(copyElement);
|
|
560
|
+
const sourceBBox = ((_b = sourceElement.getBBox) == null ? void 0 : _b.call(sourceElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
561
|
+
const targetBBox = ((_c = targetElement.getBBox) == null ? void 0 : _c.call(targetElement)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
562
|
+
const sourceCenterX = sourceBBox.x + sourceBBox.width / 2;
|
|
563
|
+
const sourceCenterY = sourceBBox.y + sourceBBox.height / 2;
|
|
564
|
+
const targetCenterX = targetBBox.x + targetBBox.width / 2;
|
|
565
|
+
const targetCenterY = targetBBox.y + targetBBox.height / 2;
|
|
566
|
+
const scaleX = targetBBox.width / (sourceBBox.width || 1);
|
|
567
|
+
const scaleY = targetBBox.height / (sourceBBox.height || 1);
|
|
568
|
+
gsap2.set(copyElement, {
|
|
569
|
+
transformOrigin: `${sourceCenterX}px ${sourceCenterY}px`
|
|
570
|
+
});
|
|
571
|
+
timeline.add(copyElement, {
|
|
572
|
+
scaleX: isFinite(scaleX) ? scaleX : 1,
|
|
573
|
+
scaleY: isFinite(scaleY) ? scaleY : 1,
|
|
574
|
+
x: targetCenterX - sourceCenterX,
|
|
575
|
+
y: targetCenterY - sourceCenterY,
|
|
576
|
+
opacity: 0,
|
|
577
|
+
duration,
|
|
578
|
+
ease: getGSAPEasing(easing),
|
|
579
|
+
delay,
|
|
580
|
+
onComplete: () => {
|
|
581
|
+
copyElement.remove();
|
|
582
|
+
gsap2.set(targetElement, { opacity: 1 });
|
|
583
|
+
}
|
|
584
|
+
}, startTime);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export {
|
|
590
|
+
__spreadValues,
|
|
591
|
+
__spreadProps,
|
|
592
|
+
__objRest,
|
|
593
|
+
Timeline,
|
|
594
|
+
createTimeline,
|
|
595
|
+
easingMap,
|
|
596
|
+
getGSAPEasing,
|
|
597
|
+
querySelectorAllIncludingSelf,
|
|
598
|
+
Transform,
|
|
599
|
+
ReplacementTransform,
|
|
600
|
+
MoveToTarget,
|
|
601
|
+
Morphing,
|
|
602
|
+
TransformMatchingShapes,
|
|
603
|
+
TransformMatchingTex,
|
|
604
|
+
ClockwiseTransform,
|
|
605
|
+
CounterclockwiseTransform,
|
|
606
|
+
TransformFromCopy
|
|
607
|
+
};
|