viewfx 0.0.5

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/src/engine.cjs ADDED
@@ -0,0 +1,161 @@
1
+ const { maskVariables } = require('./masks.cjs')
2
+ const { mosaicNewRoot } = require('./mosaic.cjs')
3
+
4
+ const expoOut = `linear(0 0%,0.1684 2.66%,0.3165 5.49%,0.446 8.52%,0.5581 11.78%,0.6535 15.29%,0.7341 19.11%,0.8011 23.3%,0.8557 27.93%,0.8962 32.68%,0.9283 38.01%,0.9529 44.08%,0.9711 51.14%,0.9833 59.06%,0.9915 68.74%,1 100%)`
5
+ const expoIn = `linear(0 0%,0.0085 31.26%,0.0167 40.94%,0.0289 48.86%,0.0471 55.92%,0.0717 61.99%,0.1038 67.32%,0.1443 72.07%,0.1989 76.7%,0.2659 80.89%,0.3465 84.71%,0.4419 88.22%,0.554 91.48%,0.6835 94.51%,0.8316 97.34%,1 100%)`
6
+
7
+ const duration = 'var(--fx-duration-override, var(--fx-duration, 0.5s))'
8
+ const ease = 'var(--fx-ease-override, var(--fx-ease, var(--expo-out)))'
9
+ const delay = 'var(--fx-delay, 0s)'
10
+
11
+ function engineBase() {
12
+ return {
13
+ ':root': {
14
+ ...maskVariables(),
15
+ '--expo-out': expoOut,
16
+ '--expo-in': expoIn
17
+ },
18
+ ':root::view-transition-group(root)': {
19
+ animationDuration: duration,
20
+ animationTimingFunction: ease,
21
+ animationDelay: delay
22
+ },
23
+ ':root::view-transition-old(root)': {
24
+ animation: `var(--fx-anim-old, fx-fade-out) ${duration} ${ease} ${delay} both`,
25
+ zIndex: 'var(--fx-old-z, auto)',
26
+ mixBlendMode: 'normal'
27
+ },
28
+ ':root::view-transition-new(root)': {
29
+ mask: 'var(--fx-mask, none) var(--fx-mask-position, center) / 0 no-repeat',
30
+ maskOrigin: 'content-box',
31
+ animation: `var(--fx-anim, fx-fade-in) ${duration} ${ease} ${delay} both`,
32
+ mixBlendMode: 'normal'
33
+ },
34
+ '@media (prefers-reduced-motion: reduce)': {
35
+ '::view-transition-group(root), ::view-transition-old(root), ::view-transition-new(root)': {
36
+ animation: 'none !important'
37
+ }
38
+ },
39
+ '@property --fx-mosaic': {
40
+ syntax: '"<number>"',
41
+ inherits: 'false',
42
+ initialValue: '1'
43
+ },
44
+ ':root.mosaic::view-transition-new(root), :root[class*="mosaic-duration"]::view-transition-new(root)':
45
+ mosaicNewRoot,
46
+ '@keyframes fx-mosaic': {
47
+ from: { '--fx-mosaic': '0' },
48
+ to: { '--fx-mosaic': '1' }
49
+ },
50
+ '@keyframes fx-mask-grow': {
51
+ to: { maskSize: 'var(--fx-mask-size)' }
52
+ },
53
+ '@keyframes fx-spiral': {
54
+ to: {
55
+ maskSize: 'var(--fx-mask-size)',
56
+ maskImage: 'conic-gradient(from 0deg, #fff 0%, #fff 100%)'
57
+ }
58
+ },
59
+ '@keyframes fx-reveal-light': {
60
+ from: { clipPath: 'polygon(171% 50%, 50% 171%, 50% 171%, 171% 50%)' },
61
+ to: { clipPath: 'polygon(171% 50%, 50% 171%, -50% 71%, 50% -71%)' }
62
+ },
63
+ '@keyframes fx-reveal-dark': {
64
+ from: { clipPath: 'polygon(50% -71%, -50% 71%, -50% 71%, 50% -71%)' },
65
+ to: { clipPath: 'polygon(50% -71%, -50% 71%, 50% 171%, 171% 50%)' }
66
+ },
67
+ '@keyframes fx-wipe-in-h': {
68
+ from: { clipPath: 'inset(0 100% 0 0)' },
69
+ to: { clipPath: 'inset(0 0 0 0)' }
70
+ },
71
+ '@keyframes fx-wipe-out-h': {
72
+ from: { clipPath: 'inset(0 0 0 0)' },
73
+ to: { clipPath: 'inset(0 0 0 100%)' }
74
+ },
75
+ '@keyframes fx-wipe-in-left': {
76
+ from: { clipPath: 'inset(0 0 0 100%)' },
77
+ to: { clipPath: 'inset(0 0 0 0)' }
78
+ },
79
+ '@keyframes fx-wipe-out-left': {
80
+ from: { clipPath: 'inset(0 0 0 0)' },
81
+ to: { clipPath: 'inset(0 100% 0 0)' }
82
+ },
83
+ '@keyframes fx-wipe-in-down': {
84
+ from: { clipPath: 'inset(0 0 100% 0)' },
85
+ to: { clipPath: 'inset(0 0 0 0)' }
86
+ },
87
+ '@keyframes fx-wipe-out-down': {
88
+ from: { clipPath: 'inset(0 0 0 0)' },
89
+ to: { clipPath: 'inset(100% 0 0 0)' }
90
+ },
91
+ '@keyframes fx-wipe-in-up': {
92
+ from: { clipPath: 'inset(100% 0 0 0)' },
93
+ to: { clipPath: 'inset(0 0 0 0)' }
94
+ },
95
+ '@keyframes fx-wipe-out-up': {
96
+ from: { clipPath: 'inset(0 0 0 0)' },
97
+ to: { clipPath: 'inset(0 0 100% 0)' }
98
+ },
99
+ '@keyframes fx-venetian-out': {
100
+ from: { clipPath: 'inset(0 0 0 0)' },
101
+ to: { clipPath: 'inset(100% 0 0 0)' }
102
+ },
103
+ '@keyframes fx-expand-in': {
104
+ from: { clipPath: 'inset(50%)' },
105
+ to: { clipPath: 'inset(0)' }
106
+ },
107
+ '@keyframes fx-glitch-in': {
108
+ '0%': { clipPath: 'inset(16% 0 6% 0)', transform: 'translateX(-3.2%) skewX(-1.5deg)' },
109
+ '14%': { clipPath: 'inset(3% 0 20% 10%)', transform: 'translateX(3.6%) skewX(2deg)' },
110
+ '28%': { clipPath: 'inset(0 14% 8% 0)', transform: 'translateX(-2.8%) skewX(-0.8deg)' },
111
+ '42%': { clipPath: 'inset(18% 0 4% 0)', transform: 'translateX(4%) skewX(1.2deg)' },
112
+ '56%': { clipPath: 'inset(5% 8% 14% 0)', transform: 'translateX(-3%) skewX(-1deg)' },
113
+ '70%': { clipPath: 'inset(0)', transform: 'translateX(0) skewX(0)' },
114
+ '84%': { clipPath: 'inset(10% 0 4% 8%)', transform: 'translateX(2.4%) skewX(0.8deg)' },
115
+ '100%': { clipPath: 'inset(0)', transform: 'translateX(0) skewX(0)' }
116
+ },
117
+ '@keyframes fx-glitch-out': {
118
+ '0%': { clipPath: 'inset(0)', transform: 'translateX(0) skewX(0)', opacity: '1' },
119
+ '16%': { clipPath: 'inset(0 0 16% 6%)', transform: 'translateX(3%) skewX(1.2deg)' },
120
+ '32%': { clipPath: 'inset(14% 10% 4% 0)', transform: 'translateX(-3.4%) skewX(-1.5deg)' },
121
+ '48%': { clipPath: 'inset(4% 0 18% 0)', transform: 'translateX(2.6%) skewX(0.6deg)' },
122
+ '64%': { clipPath: 'inset(12% 6% 6% 0)', transform: 'translateX(-2.2%) skewX(-1deg)' },
123
+ '80%': { clipPath: 'inset(6% 0 12% 8%)', transform: 'translateX(2%) skewX(0.8deg)', opacity: '0.85' },
124
+ '100%': { clipPath: 'inset(20% 0 16% 0)', transform: 'translateX(-1.5%) skewX(0)', opacity: '0' }
125
+ },
126
+ '@keyframes fx-slide-in': {
127
+ from: { transform: 'translateX(100%)' },
128
+ to: { transform: 'translateX(0)' }
129
+ },
130
+ '@keyframes fx-slide-out': {
131
+ from: { transform: 'translateX(0)', opacity: '1' },
132
+ to: { transform: 'translateX(-50%)', opacity: '0.3' }
133
+ },
134
+ '@keyframes fx-zoom-in': {
135
+ from: { opacity: '0', transform: 'scale(0.85)' },
136
+ to: { opacity: '1', transform: 'scale(1)' }
137
+ },
138
+ '@keyframes fx-zoom-out': {
139
+ from: { opacity: '1', transform: 'scale(1)' },
140
+ to: { opacity: '0', transform: 'scale(1.15)' }
141
+ },
142
+ '@keyframes fx-rotate-in': {
143
+ from: { opacity: '0', transform: 'rotate(-6deg) scale(0.9)' },
144
+ to: { opacity: '1', transform: 'rotate(0) scale(1)' }
145
+ },
146
+ '@keyframes fx-rotate-out': {
147
+ from: { opacity: '1', transform: 'rotate(0) scale(1)' },
148
+ to: { opacity: '0', transform: 'rotate(6deg) scale(0.9)' }
149
+ },
150
+ '@keyframes fx-fade-in': {
151
+ from: { opacity: '0' },
152
+ to: { opacity: '1' }
153
+ },
154
+ '@keyframes fx-fade-out': {
155
+ from: { opacity: '1' },
156
+ to: { opacity: '0' }
157
+ }
158
+ }
159
+ }
160
+
161
+ module.exports = { engineBase }