laymur-animations 0.25.0 → 0.26.0
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/README.md +6 -0
- package/dist/UIAnimatedElement.d.ts +10 -3
- package/dist/UIAnimatedElement.js +1 -0
- package/dist/UIAppearAnimator.d.ts +7 -3
- package/dist/UIAppearAnimator.js +71 -0
- package/dist/UIClickAnimator.d.ts +11 -4
- package/dist/UIClickAnimator.js +83 -0
- package/dist/UIDisappearAnimator.d.ts +11 -3
- package/dist/UIDisappearAnimator.js +53 -0
- package/dist/UIFlashAnimator.d.ts +39 -0
- package/dist/UIFlashAnimator.js +43 -0
- package/dist/UIFloatCallAnimator.d.ts +45 -0
- package/dist/UIFloatCallAnimator.js +67 -0
- package/dist/UIFlyToAnimator.d.ts +57 -0
- package/dist/UIFlyToAnimator.js +60 -0
- package/dist/UIJumpCallAnimator.d.ts +10 -6
- package/dist/UIJumpCallAnimator.js +97 -0
- package/dist/UIPulseCallAnimator.d.ts +11 -6
- package/dist/UIPulseCallAnimator.js +67 -0
- package/dist/UIShakeAnimator.d.ts +31 -0
- package/dist/UIShakeAnimator.js +49 -0
- package/dist/UIShineCallAnimator.d.ts +49 -0
- package/dist/UIShineCallAnimator.js +74 -0
- package/dist/UISpinCallAnimator.d.ts +8 -5
- package/dist/UISpinCallAnimator.js +74 -0
- package/dist/UISwipeCallAnimator.d.ts +9 -6
- package/dist/UISwipeCallAnimator.js +64 -0
- package/dist/UITapCallAnimator.d.ts +64 -0
- package/dist/UITapCallAnimator.js +83 -0
- package/dist/index.d.ts +27 -7
- package/dist/index.js +13 -509
- package/dist/miscellaneous.d.ts +71 -0
- package/dist/miscellaneous.js +163 -0
- package/package.json +25 -39
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,509 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Animator for element appearance effects.
|
|
16
|
-
*/
|
|
17
|
-
class UIAppearAnimator {
|
|
18
|
-
/**
|
|
19
|
-
* Animates elements appearing with position, scale, and alpha transitions.
|
|
20
|
-
* @param target - Single element or array of elements to animate
|
|
21
|
-
* @param options - Animation configuration options
|
|
22
|
-
* @returns Promise that resolves when animation completes
|
|
23
|
-
*/
|
|
24
|
-
static appear(target, options = {}) {
|
|
25
|
-
const { xFrom = DEFAULT_X_FROM, xTo = DEFAULT_X_TO, yFrom = DEFAULT_Y_FROM, yTo = DEFAULT_Y_TO, scaleFrom = DEFAULT_SCALE_FROM, scaleTo = DEFAULT_SCALE_TO, alphaFrom = DEFAULT_ALPHA_FROM, alphaTo = DEFAULT_ALPHA_TO$1, delay = DEFAULT_DELAY$2, duration = DEFAULT_DURATION$3, ease = DEFAULT_EASE$2, } = options;
|
|
26
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
27
|
-
const colorTarget = {
|
|
28
|
-
duration,
|
|
29
|
-
ease: "power1.inOut",
|
|
30
|
-
};
|
|
31
|
-
const microTarget = { duration, ease };
|
|
32
|
-
if (xFrom !== xTo) {
|
|
33
|
-
microTarget.x = xTo;
|
|
34
|
-
for (const element of elements) {
|
|
35
|
-
element.micro.x = xFrom;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (yFrom !== yTo) {
|
|
39
|
-
microTarget.y = yTo;
|
|
40
|
-
for (const element of elements) {
|
|
41
|
-
element.micro.y = yFrom;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (scaleFrom !== scaleTo) {
|
|
45
|
-
microTarget.scaleX = scaleTo;
|
|
46
|
-
microTarget.scaleY = scaleTo;
|
|
47
|
-
for (const element of elements) {
|
|
48
|
-
element.micro.scaleX = scaleFrom;
|
|
49
|
-
element.micro.scaleY = scaleFrom;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (alphaFrom !== alphaTo) {
|
|
53
|
-
colorTarget.a = alphaTo;
|
|
54
|
-
for (const element of elements) {
|
|
55
|
-
element.color.a = alphaFrom;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return new Promise((onComplete) => {
|
|
59
|
-
const timeline = gsap.timeline({ delay, onComplete });
|
|
60
|
-
for (const element of elements) {
|
|
61
|
-
timeline.to(element.micro, microTarget, 0).to(element.color, colorTarget, 0);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const DEFAULT_X_OFFSET = 0;
|
|
68
|
-
const DEFAULT_Y_OFFSET = -25;
|
|
69
|
-
const DEFAULT_X_SCALE = 0.85;
|
|
70
|
-
const DEFAULT_Y_SCALE = 1;
|
|
71
|
-
const DEFAULT_DELAY$1 = 0;
|
|
72
|
-
const DEFAULT_DURATION_IN$2 = 0.125;
|
|
73
|
-
const DEFAULT_DURATION_OUT$2 = 0.25;
|
|
74
|
-
const DEFAULT_EASE_IN$3 = "power1.out";
|
|
75
|
-
const DEFAULT_EASE_OUT$3 = "back.out";
|
|
76
|
-
/**
|
|
77
|
-
* Animator for click feedback effects.
|
|
78
|
-
*/
|
|
79
|
-
class UIClickAnimator {
|
|
80
|
-
/**
|
|
81
|
-
* Animates elements with click feedback including position offset and scale effects.
|
|
82
|
-
* @param target - Single element or array of elements to animate
|
|
83
|
-
* @param options - Animation configuration options
|
|
84
|
-
* @returns Promise that resolves when animation completes
|
|
85
|
-
*/
|
|
86
|
-
static click(target, options = {}) {
|
|
87
|
-
const { xOffset = DEFAULT_X_OFFSET, yOffset = DEFAULT_Y_OFFSET, xScale = DEFAULT_X_SCALE, yScale = DEFAULT_Y_SCALE, delay = DEFAULT_DELAY$1, durationIn = DEFAULT_DURATION_IN$2, durationOut = DEFAULT_DURATION_OUT$2, easeIn = DEFAULT_EASE_IN$3, easeOut = DEFAULT_EASE_OUT$3, } = options;
|
|
88
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
89
|
-
return new Promise((onComplete) => {
|
|
90
|
-
const timeline = gsap.timeline({ onComplete });
|
|
91
|
-
const inMicroTarget = {
|
|
92
|
-
delay,
|
|
93
|
-
duration: durationIn,
|
|
94
|
-
ease: easeIn,
|
|
95
|
-
};
|
|
96
|
-
const outMicroTarget = {
|
|
97
|
-
duration: durationOut,
|
|
98
|
-
ease: easeOut,
|
|
99
|
-
};
|
|
100
|
-
if (xOffset !== 0) {
|
|
101
|
-
inMicroTarget.x = xOffset;
|
|
102
|
-
outMicroTarget.x = 0;
|
|
103
|
-
}
|
|
104
|
-
if (yOffset !== 0) {
|
|
105
|
-
inMicroTarget.y = yOffset;
|
|
106
|
-
outMicroTarget.y = 0;
|
|
107
|
-
}
|
|
108
|
-
if (xScale !== 1) {
|
|
109
|
-
inMicroTarget.scaleX = xScale;
|
|
110
|
-
outMicroTarget.scaleX = 1;
|
|
111
|
-
}
|
|
112
|
-
if (yScale !== 1) {
|
|
113
|
-
inMicroTarget.scaleY = yScale;
|
|
114
|
-
outMicroTarget.scaleY = 1;
|
|
115
|
-
}
|
|
116
|
-
for (const element of elements) {
|
|
117
|
-
timeline.to(element.micro, inMicroTarget, 0).to(element.micro, outMicroTarget);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const DEFAULT_DELAY = 0;
|
|
124
|
-
const DEFAULT_DURATION$2 = 0.25;
|
|
125
|
-
const DEFAULT_EASE$1 = "back.in(1.7)";
|
|
126
|
-
const DEFAULT_ALPHA_TO = 0;
|
|
127
|
-
/**
|
|
128
|
-
* Animator for element disappearance effects.
|
|
129
|
-
*/
|
|
130
|
-
class UIDisappearAnimator {
|
|
131
|
-
/**
|
|
132
|
-
* Animates elements disappearing with position, scale, and alpha transitions.
|
|
133
|
-
* @param target - Single element or array of elements to animate
|
|
134
|
-
* @param options - Animation configuration options
|
|
135
|
-
* @returns Promise that resolves when animation completes
|
|
136
|
-
*/
|
|
137
|
-
static disappear(target, options = {}) {
|
|
138
|
-
const { delay = DEFAULT_DELAY, duration = DEFAULT_DURATION$2, ease = DEFAULT_EASE$1, alphaTo = DEFAULT_ALPHA_TO, } = options;
|
|
139
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
140
|
-
const microTarget = { duration, ease };
|
|
141
|
-
const colorTarget = {
|
|
142
|
-
duration,
|
|
143
|
-
ease: "power1.inOut",
|
|
144
|
-
a: alphaTo,
|
|
145
|
-
};
|
|
146
|
-
if (options.xTo !== undefined) {
|
|
147
|
-
microTarget.x = options.xTo;
|
|
148
|
-
}
|
|
149
|
-
if (options.yTo !== undefined) {
|
|
150
|
-
microTarget.y = options.yTo;
|
|
151
|
-
}
|
|
152
|
-
if (options.scaleTo !== undefined) {
|
|
153
|
-
microTarget.scaleX = options.scaleTo;
|
|
154
|
-
microTarget.scaleY = options.scaleTo;
|
|
155
|
-
}
|
|
156
|
-
return new Promise((onComplete) => {
|
|
157
|
-
const timeline = gsap.timeline({ delay, onComplete });
|
|
158
|
-
for (const element of elements) {
|
|
159
|
-
timeline.to(element.micro, microTarget, 0).to(element.color, colorTarget, 0);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const jumpCallTweens = new WeakMap();
|
|
166
|
-
const DEFAULT_JUMP_HEIGHT = 35;
|
|
167
|
-
const DEFAULT_SCALE_IN = 1.15;
|
|
168
|
-
const DEFAULT_SCALE_OUT = 1.15;
|
|
169
|
-
const DEFAULT_ITERATIONS$3 = -1;
|
|
170
|
-
const DEFAULT_COOLDOWN$3 = 3;
|
|
171
|
-
const DEFAULT_START_WITH_COOLDOWN$3 = true;
|
|
172
|
-
const DEFAULT_DURATION_IN$1 = 0.5;
|
|
173
|
-
const DEFAULT_DURATION_OUT$1 = 0.5;
|
|
174
|
-
const DEFAULT_EASE_IN$2 = "power1.out";
|
|
175
|
-
const DEFAULT_EASE_OUT$2 = "power1.in";
|
|
176
|
-
const DEFAULT_STOP_DURATION$3 = 0.25;
|
|
177
|
-
const DEFAULT_STOP_EASE$3 = "power1.inOut";
|
|
178
|
-
/**
|
|
179
|
-
* Animator for jump call attention effects.
|
|
180
|
-
*/
|
|
181
|
-
class UIJumpCallAnimator {
|
|
182
|
-
/**
|
|
183
|
-
* Starts a jumping animation with scale and position effects.
|
|
184
|
-
* @param target - Single element or array of elements to animate
|
|
185
|
-
* @param options - Animation configuration options
|
|
186
|
-
*/
|
|
187
|
-
static jump(target, options = {}) {
|
|
188
|
-
const { jumpHeight = DEFAULT_JUMP_HEIGHT, scaleIn = DEFAULT_SCALE_IN, scaleOut = DEFAULT_SCALE_OUT, iterations = DEFAULT_ITERATIONS$3, cooldown = DEFAULT_COOLDOWN$3, startWithCooldown = DEFAULT_START_WITH_COOLDOWN$3, durationIn = DEFAULT_DURATION_IN$1, durationOut = DEFAULT_DURATION_OUT$1, easeIn = DEFAULT_EASE_IN$2, easeOut = DEFAULT_EASE_OUT$2, } = options;
|
|
189
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
190
|
-
for (const element of elements) {
|
|
191
|
-
const timeline = gsap.timeline({
|
|
192
|
-
repeat: Number.isNaN(iterations) ? -1 : iterations,
|
|
193
|
-
onComplete: () => {
|
|
194
|
-
jumpCallTweens.delete(element);
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
if (startWithCooldown && cooldown > 0) {
|
|
198
|
-
timeline.to({}, { duration: cooldown });
|
|
199
|
-
}
|
|
200
|
-
element.micro.anchorY = 0;
|
|
201
|
-
timeline
|
|
202
|
-
.to(element.micro, {
|
|
203
|
-
scaleX: scaleIn,
|
|
204
|
-
scaleY: 1 / scaleIn,
|
|
205
|
-
duration: durationIn * 0.5,
|
|
206
|
-
ease: "power1.inOut",
|
|
207
|
-
})
|
|
208
|
-
.to(element.micro, {
|
|
209
|
-
scaleX: 1 / scaleIn,
|
|
210
|
-
scaleY: scaleIn,
|
|
211
|
-
duration: durationIn * 0.25,
|
|
212
|
-
ease: "power1.inOut",
|
|
213
|
-
})
|
|
214
|
-
.to(element.micro, {
|
|
215
|
-
scaleX: 1,
|
|
216
|
-
scaleY: 1,
|
|
217
|
-
duration: durationIn * 0.25,
|
|
218
|
-
ease: "power1.inOut",
|
|
219
|
-
})
|
|
220
|
-
.to(element.micro, {
|
|
221
|
-
y: jumpHeight,
|
|
222
|
-
duration: durationIn * 0.375,
|
|
223
|
-
ease: easeIn,
|
|
224
|
-
}, durationIn * 0.625 + (startWithCooldown && cooldown > 0 ? cooldown : 0))
|
|
225
|
-
.to(element.micro, {
|
|
226
|
-
y: 0,
|
|
227
|
-
duration: durationOut * 0.375,
|
|
228
|
-
ease: easeOut,
|
|
229
|
-
})
|
|
230
|
-
.to(element.micro, {
|
|
231
|
-
scaleX: scaleOut,
|
|
232
|
-
scaleY: 1 / scaleOut,
|
|
233
|
-
duration: durationOut * 0.225,
|
|
234
|
-
ease: "power1.out",
|
|
235
|
-
})
|
|
236
|
-
.to(element.micro, {
|
|
237
|
-
scaleX: 1,
|
|
238
|
-
scaleY: 1,
|
|
239
|
-
duration: durationOut * 0.4,
|
|
240
|
-
ease: "power1.inOut",
|
|
241
|
-
});
|
|
242
|
-
if (!startWithCooldown && cooldown > 0) {
|
|
243
|
-
timeline.to({}, { duration: cooldown });
|
|
244
|
-
}
|
|
245
|
-
jumpCallTweens.set(element, timeline);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Stops the jumping animation and returns elements to rest position.
|
|
250
|
-
* @param target - Single element or array of elements to stop animating
|
|
251
|
-
* @param options - Stop animation configuration options
|
|
252
|
-
*/
|
|
253
|
-
static stopJump(target, options = {}) {
|
|
254
|
-
const { duration = DEFAULT_STOP_DURATION$3, ease = DEFAULT_STOP_EASE$3 } = options;
|
|
255
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
256
|
-
for (const element of elements) {
|
|
257
|
-
const tween = jumpCallTweens.get(element);
|
|
258
|
-
if (tween instanceof gsap.core.Timeline) {
|
|
259
|
-
tween.kill();
|
|
260
|
-
jumpCallTweens.delete(element);
|
|
261
|
-
gsap.to(element.micro, {
|
|
262
|
-
y: 0,
|
|
263
|
-
duration,
|
|
264
|
-
ease,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const pulseCallTweens = new WeakMap();
|
|
272
|
-
const DEFAULT_SCALE = 1.1;
|
|
273
|
-
const DEFAULT_ITERATIONS$2 = -1;
|
|
274
|
-
const DEFAULT_COOLDOWN$2 = 3;
|
|
275
|
-
const DEFAULT_START_WITH_COOLDOWN$2 = true;
|
|
276
|
-
const DEFAULT_DURATION_IN = 0.25;
|
|
277
|
-
const DEFAULT_DURATION_OUT = 0.5;
|
|
278
|
-
const DEFAULT_EASE_IN$1 = "power1.inOut";
|
|
279
|
-
const DEFAULT_EASE_OUT$1 = "power1.inOut";
|
|
280
|
-
const DEFAULT_STOP_SCALE = 1;
|
|
281
|
-
const DEFAULT_STOP_DURATION$2 = 0.25;
|
|
282
|
-
const DEFAULT_STOP_EASE$2 = "power1.inOut";
|
|
283
|
-
/**
|
|
284
|
-
* Animator for pulse attention effects.
|
|
285
|
-
*/
|
|
286
|
-
class UIPulseCallAnimator {
|
|
287
|
-
/**
|
|
288
|
-
* Starts a pulsing animation with scale effects.
|
|
289
|
-
* @param target - Single element or array of elements to animate
|
|
290
|
-
* @param options - Animation configuration options
|
|
291
|
-
*/
|
|
292
|
-
static pulse(target, options = {}) {
|
|
293
|
-
const { scale = DEFAULT_SCALE, iterations = DEFAULT_ITERATIONS$2, cooldown = DEFAULT_COOLDOWN$2, startWithCooldown = DEFAULT_START_WITH_COOLDOWN$2, durationIn = DEFAULT_DURATION_IN, durationOut = DEFAULT_DURATION_OUT, easeIn = DEFAULT_EASE_IN$1, easeOut = DEFAULT_EASE_OUT$1, } = options;
|
|
294
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
295
|
-
for (const element of elements) {
|
|
296
|
-
const timeline = gsap.timeline({
|
|
297
|
-
repeat: Number.isNaN(iterations) ? -1 : iterations,
|
|
298
|
-
onComplete: () => {
|
|
299
|
-
pulseCallTweens.delete(element);
|
|
300
|
-
},
|
|
301
|
-
});
|
|
302
|
-
if (startWithCooldown && cooldown > 0) {
|
|
303
|
-
timeline.to({}, { duration: cooldown });
|
|
304
|
-
}
|
|
305
|
-
timeline
|
|
306
|
-
.to(element.micro, {
|
|
307
|
-
scaleX: scale,
|
|
308
|
-
scaleY: scale,
|
|
309
|
-
duration: durationIn,
|
|
310
|
-
ease: easeIn,
|
|
311
|
-
})
|
|
312
|
-
.to(element.micro, {
|
|
313
|
-
scaleX: element.micro.scaleX,
|
|
314
|
-
scaleY: element.micro.scaleY,
|
|
315
|
-
duration: durationOut,
|
|
316
|
-
ease: easeOut,
|
|
317
|
-
});
|
|
318
|
-
if (!startWithCooldown && cooldown > 0) {
|
|
319
|
-
timeline.to({}, { duration: cooldown });
|
|
320
|
-
}
|
|
321
|
-
pulseCallTweens.set(element, timeline);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Stops the pulsing animation and returns elements to rest scale.
|
|
326
|
-
* @param target - Single element or array of elements to stop animating
|
|
327
|
-
* @param options - Stop animation configuration options
|
|
328
|
-
*/
|
|
329
|
-
static stopPulse(target, options = {}) {
|
|
330
|
-
const { scale = DEFAULT_STOP_SCALE, duration = DEFAULT_STOP_DURATION$2, ease = DEFAULT_STOP_EASE$2, } = options;
|
|
331
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
332
|
-
for (const element of elements) {
|
|
333
|
-
const tween = pulseCallTweens.get(element);
|
|
334
|
-
if (tween instanceof gsap.core.Timeline) {
|
|
335
|
-
tween.kill();
|
|
336
|
-
pulseCallTweens.delete(element);
|
|
337
|
-
gsap.to(element.micro, {
|
|
338
|
-
scaleX: scale,
|
|
339
|
-
scaleY: scale,
|
|
340
|
-
duration,
|
|
341
|
-
ease,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const spinCallTweens = new WeakMap();
|
|
349
|
-
const DEFAULT_ROTATION = 0.0435;
|
|
350
|
-
const DEFAULT_ANCHOR_X = 0.5;
|
|
351
|
-
const DEFAULT_ANCHOR_Y = 0.5;
|
|
352
|
-
const DEFAULT_SPIN_COUNT = 3;
|
|
353
|
-
const DEFAULT_ITERATIONS$1 = -1;
|
|
354
|
-
const DEFAULT_COOLDOWN$1 = 3;
|
|
355
|
-
const DEFAULT_START_WITH_COOLDOWN$1 = true;
|
|
356
|
-
const DEFAULT_DURATION$1 = 1;
|
|
357
|
-
const DEFAULT_EASE = "power1.inOut";
|
|
358
|
-
const DEFAULT_STOP_DURATION$1 = 0.25;
|
|
359
|
-
const DEFAULT_STOP_EASE$1 = "power1.inOut";
|
|
360
|
-
/**
|
|
361
|
-
* Animator for spin call attention effects.
|
|
362
|
-
*/
|
|
363
|
-
class UISpinCallAnimator {
|
|
364
|
-
/**
|
|
365
|
-
* Starts a spinning animation with rotation oscillations.
|
|
366
|
-
* @param target - Single element or array of elements to animate
|
|
367
|
-
* @param options - Animation configuration options
|
|
368
|
-
*/
|
|
369
|
-
static spin(target, options = {}) {
|
|
370
|
-
const { rotation = DEFAULT_ROTATION, anchorX = DEFAULT_ANCHOR_X, anchorY = DEFAULT_ANCHOR_Y, spinCount = DEFAULT_SPIN_COUNT, iterations = DEFAULT_ITERATIONS$1, cooldown = DEFAULT_COOLDOWN$1, startWithCooldown = DEFAULT_START_WITH_COOLDOWN$1, duration = DEFAULT_DURATION$1, ease = DEFAULT_EASE, } = options;
|
|
371
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
372
|
-
for (const element of elements) {
|
|
373
|
-
element.micro.anchorX = anchorX;
|
|
374
|
-
element.micro.anchorY = anchorY;
|
|
375
|
-
const timeline = gsap.timeline({
|
|
376
|
-
repeat: Number.isNaN(iterations) ? -1 : iterations,
|
|
377
|
-
onComplete: () => {
|
|
378
|
-
spinCallTweens.delete(element);
|
|
379
|
-
},
|
|
380
|
-
});
|
|
381
|
-
if (startWithCooldown && cooldown > 0) {
|
|
382
|
-
timeline.to({}, { duration: cooldown });
|
|
383
|
-
}
|
|
384
|
-
const spinDuration = duration / (spinCount + 2);
|
|
385
|
-
timeline.to(element.micro, {
|
|
386
|
-
rotation,
|
|
387
|
-
duration: spinDuration,
|
|
388
|
-
ease,
|
|
389
|
-
});
|
|
390
|
-
let currentRotation = rotation;
|
|
391
|
-
for (let i = 0; i < spinCount; i++) {
|
|
392
|
-
timeline.to(element.micro, {
|
|
393
|
-
rotation: (currentRotation *= -1),
|
|
394
|
-
duration: spinDuration,
|
|
395
|
-
ease,
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
timeline.to(element.micro, {
|
|
399
|
-
rotation: 0,
|
|
400
|
-
duration: spinDuration,
|
|
401
|
-
ease,
|
|
402
|
-
});
|
|
403
|
-
if (!startWithCooldown && cooldown > 0) {
|
|
404
|
-
timeline.to({}, { duration: cooldown });
|
|
405
|
-
}
|
|
406
|
-
spinCallTweens.set(element, timeline);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Stops the spinning animation and returns elements to rest rotation.
|
|
411
|
-
* @param target - Single element or array of elements to stop animating
|
|
412
|
-
* @param options - Stop animation configuration options
|
|
413
|
-
*/
|
|
414
|
-
static stopSpin(target, options = {}) {
|
|
415
|
-
const { duration = DEFAULT_STOP_DURATION$1, ease = DEFAULT_STOP_EASE$1 } = options;
|
|
416
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
417
|
-
for (const element of elements) {
|
|
418
|
-
const tween = spinCallTweens.get(element);
|
|
419
|
-
if (tween instanceof gsap.core.Timeline) {
|
|
420
|
-
tween.kill();
|
|
421
|
-
spinCallTweens.delete(element);
|
|
422
|
-
gsap.to(element.micro, {
|
|
423
|
-
rotation: 0,
|
|
424
|
-
duration,
|
|
425
|
-
ease,
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const swipeCallTweens = new WeakMap();
|
|
433
|
-
const DEFAULT_DX = 25;
|
|
434
|
-
const DEFAULT_DY = 0;
|
|
435
|
-
const DEFAULT_ITERATIONS = -1;
|
|
436
|
-
const DEFAULT_COOLDOWN = 0;
|
|
437
|
-
const DEFAULT_START_WITH_COOLDOWN = false;
|
|
438
|
-
const DEFAULT_DURATION = 0.4;
|
|
439
|
-
const DEFAULT_EASE_IN = "power1.inOut";
|
|
440
|
-
const DEFAULT_EASE_OUT = "power1.inOut";
|
|
441
|
-
const DEFAULT_STOP_DURATION = 0.25;
|
|
442
|
-
const DEFAULT_STOP_EASE = "power1.inOut";
|
|
443
|
-
/**
|
|
444
|
-
* Animator for swipe call attention effects with pingpong movement along an arbitrary vector.
|
|
445
|
-
*/
|
|
446
|
-
class UISwipeCallAnimator {
|
|
447
|
-
/**
|
|
448
|
-
* Starts an infinite pingpong swipe animation along the vector (dx, dy).
|
|
449
|
-
* @param target - Single element or array of elements to animate
|
|
450
|
-
* @param options - Animation configuration options
|
|
451
|
-
*/
|
|
452
|
-
static swipe(target, options = {}) {
|
|
453
|
-
const { dx = DEFAULT_DX, dy = DEFAULT_DY, iterations = DEFAULT_ITERATIONS, cooldown = DEFAULT_COOLDOWN, startWithCooldown = DEFAULT_START_WITH_COOLDOWN, duration = DEFAULT_DURATION, easeIn = DEFAULT_EASE_IN, easeOut = DEFAULT_EASE_OUT, } = options;
|
|
454
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
455
|
-
for (const element of elements) {
|
|
456
|
-
const timeline = gsap.timeline({
|
|
457
|
-
repeat: Number.isNaN(iterations) ? -1 : iterations,
|
|
458
|
-
onComplete: () => {
|
|
459
|
-
swipeCallTweens.delete(element);
|
|
460
|
-
},
|
|
461
|
-
});
|
|
462
|
-
if (startWithCooldown && cooldown > 0) {
|
|
463
|
-
timeline.to({}, { duration: cooldown });
|
|
464
|
-
}
|
|
465
|
-
timeline
|
|
466
|
-
.to(element.micro, {
|
|
467
|
-
x: element.micro.x + dx,
|
|
468
|
-
y: element.micro.y + dy,
|
|
469
|
-
duration,
|
|
470
|
-
ease: easeIn,
|
|
471
|
-
})
|
|
472
|
-
.to(element.micro, {
|
|
473
|
-
x: element.micro.x,
|
|
474
|
-
y: element.micro.y,
|
|
475
|
-
duration,
|
|
476
|
-
ease: easeOut,
|
|
477
|
-
});
|
|
478
|
-
if (!startWithCooldown && cooldown > 0) {
|
|
479
|
-
timeline.to({}, { duration: cooldown });
|
|
480
|
-
}
|
|
481
|
-
swipeCallTweens.set(element, timeline);
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Stops the swipe animation and returns elements to rest position.
|
|
486
|
-
* @param target - Single element or array of elements to stop animating
|
|
487
|
-
* @param options - Stop animation configuration options
|
|
488
|
-
*/
|
|
489
|
-
static stopSwipe(target, options = {}) {
|
|
490
|
-
const { duration = DEFAULT_STOP_DURATION, ease = DEFAULT_STOP_EASE } = options;
|
|
491
|
-
const elements = Array.isArray(target) ? target : [target];
|
|
492
|
-
for (const element of elements) {
|
|
493
|
-
const tween = swipeCallTweens.get(element);
|
|
494
|
-
if (tween instanceof gsap.core.Timeline) {
|
|
495
|
-
tween.kill();
|
|
496
|
-
swipeCallTweens.delete(element);
|
|
497
|
-
gsap.to(element.micro, {
|
|
498
|
-
x: 0,
|
|
499
|
-
y: 0,
|
|
500
|
-
duration,
|
|
501
|
-
ease,
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
export { UIAppearAnimator, UIClickAnimator, UIDisappearAnimator, UIJumpCallAnimator, UIPulseCallAnimator, UISpinCallAnimator, UISwipeCallAnimator };
|
|
509
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { UIAppearAnimator } from "./UIAppearAnimator.js";
|
|
2
|
+
export { UIClickAnimator } from "./UIClickAnimator.js";
|
|
3
|
+
export { UIDisappearAnimator } from "./UIDisappearAnimator.js";
|
|
4
|
+
export { UIFlashAnimator } from "./UIFlashAnimator.js";
|
|
5
|
+
export { UIFloatCallAnimator } from "./UIFloatCallAnimator.js";
|
|
6
|
+
export { UIFlyToAnimator } from "./UIFlyToAnimator.js";
|
|
7
|
+
export { UIJumpCallAnimator } from "./UIJumpCallAnimator.js";
|
|
8
|
+
export { UIPulseCallAnimator } from "./UIPulseCallAnimator.js";
|
|
9
|
+
export { UIShakeAnimator } from "./UIShakeAnimator.js";
|
|
10
|
+
export { UIShineCallAnimator } from "./UIShineCallAnimator.js";
|
|
11
|
+
export { UISpinCallAnimator } from "./UISpinCallAnimator.js";
|
|
12
|
+
export { UISwipeCallAnimator } from "./UISwipeCallAnimator.js";
|
|
13
|
+
export { UITapCallAnimator } from "./UITapCallAnimator.js";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { UIMicro } from "laymur";
|
|
2
|
+
import type { UIAnimatedElement } from "./UIAnimatedElement.js";
|
|
3
|
+
/** Micro transform properties an animator may own */
|
|
4
|
+
export type UIMicroProperty = "x" | "y" | "scaleX" | "scaleY" | "rotation" | "anchorX" | "anchorY";
|
|
5
|
+
/** Values of micro properties an animation comes back to */
|
|
6
|
+
export type UIMicroRest = Record<UIMicroProperty, number>;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes a single target or an array of targets to an array.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveTargets<T>(target: T | T[]): T[];
|
|
11
|
+
/**
|
|
12
|
+
* Converts an iteration count to the gsap repeat count, which does not count the first run.
|
|
13
|
+
* @param iterations Number of runs; -1 or NaN for infinite, at least one run otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function iterationsToRepeat(iterations: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves when the animation completes, with true, or is killed before that, with false.
|
|
18
|
+
* Takes over the onComplete and onInterrupt callbacks of the animation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function settle(animation: gsap.core.Animation): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Kills the appearance or disappearance running on the element; its promise resolves.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stopVisibility(element: UIAnimatedElement): void;
|
|
25
|
+
/**
|
|
26
|
+
* Remembers the appearance or disappearance of the element, so the next one can replace it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function trackVisibility(element: UIAnimatedElement, animation: gsap.core.Animation): void;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the animation is still the appearance or disappearance of the element.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isVisibilityTracked(element: UIAnimatedElement, animation: gsap.core.Animation): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Hides the element, remembering its mode for {@link restoreMode}. Does nothing for an
|
|
35
|
+
* element without a mode.
|
|
36
|
+
*/
|
|
37
|
+
export declare function hideElement(element: UIAnimatedElement): void;
|
|
38
|
+
/**
|
|
39
|
+
* Gives an element hidden by {@link hideElement} its mode back.
|
|
40
|
+
*/
|
|
41
|
+
export declare function restoreMode(element: UIAnimatedElement): void;
|
|
42
|
+
/**
|
|
43
|
+
* Keeps track of one kind of call animation per micro.
|
|
44
|
+
*
|
|
45
|
+
* The rest values of the properties the animator owns are taken when the element is idle and
|
|
46
|
+
* kept while calls replace each other, so restarting a call mid-animation does not shift the
|
|
47
|
+
* element. Stopping brings the element back to rest; anchors are restored once it is there.
|
|
48
|
+
*/
|
|
49
|
+
export declare class UICallTracker {
|
|
50
|
+
private readonly properties;
|
|
51
|
+
private readonly entries;
|
|
52
|
+
constructor(properties: readonly UIMicroProperty[]);
|
|
53
|
+
/**
|
|
54
|
+
* Starts a call, replacing the call or the return to rest running on the micro.
|
|
55
|
+
* @param micro Micro transform to animate
|
|
56
|
+
* @param build Builds the call timeline from the rest values
|
|
57
|
+
* @param onEnd Called once when the call completes, is stopped or is replaced
|
|
58
|
+
*/
|
|
59
|
+
start(micro: UIMicro, build: (rest: UIMicroRest) => gsap.core.Timeline, onEnd?: () => void): void;
|
|
60
|
+
/**
|
|
61
|
+
* Stops the call running on the micro and brings it back to rest.
|
|
62
|
+
* @param overrides Values to come back to instead of the rest values
|
|
63
|
+
*/
|
|
64
|
+
stop(micro: UIMicro, duration: number, ease: gsap.EaseString, overrides?: Partial<UIMicroRest>): void;
|
|
65
|
+
private track;
|
|
66
|
+
/** Kills the animation of the entry without it counting as an interruption */
|
|
67
|
+
private kill;
|
|
68
|
+
private takeRest;
|
|
69
|
+
private finish;
|
|
70
|
+
private end;
|
|
71
|
+
}
|