-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
index.ts
73 lines (69 loc) · 1.49 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import type { TransitionAnimationPair, TransitionDirectionalAnimations } from '../@types/astro';
const EASE_IN_OUT_QUART = 'cubic-bezier(0.76, 0, 0.24, 1)';
export function slide({
duration,
}: {
duration?: string | number;
} = {}): TransitionDirectionalAnimations {
return {
forwards: {
old: [
{
name: 'astroFadeOut',
duration: duration ?? '90ms',
easing: EASE_IN_OUT_QUART,
fillMode: 'both',
},
{
name: 'astroSlideToLeft',
duration: duration ?? '220ms',
easing: EASE_IN_OUT_QUART,
fillMode: 'both',
},
],
new: [
{
name: 'astroFadeIn',
duration: duration ?? '210ms',
easing: EASE_IN_OUT_QUART,
delay: duration ? undefined : '30ms',
fillMode: 'both',
},
{
name: 'astroSlideFromRight',
duration: duration ?? '220ms',
easing: EASE_IN_OUT_QUART,
fillMode: 'both',
},
],
},
backwards: {
old: [{ name: 'astroFadeOut' }, { name: 'astroSlideToRight' }],
new: [{ name: 'astroFadeIn' }, { name: 'astroSlideFromLeft' }],
},
};
}
export function fade({
duration
}: {
duration?: string | number;
} = {}): TransitionDirectionalAnimations {
const anim = {
old: {
name: 'astroFadeOut',
duration: duration ?? 180,
easing: EASE_IN_OUT_QUART,
fillMode: 'both',
},
new: {
name: 'astroFadeIn',
duration: duration ?? 180,
easing: EASE_IN_OUT_QUART,
fillMode: 'both',
},
} satisfies TransitionAnimationPair;
return {
forwards: anim,
backwards: anim,
};
}