@wix/motion 1.644.0 → 1.646.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.
Files changed (204) hide show
  1. package/README.md +0 -2
  2. package/dist/cjs/api/common.js +7 -3
  3. package/dist/cjs/api/common.js.map +1 -1
  4. package/dist/cjs/api/cssAnimations.js +3 -3
  5. package/dist/cjs/api/cssAnimations.js.map +1 -1
  6. package/dist/cjs/api/webAnimations.js +5 -5
  7. package/dist/cjs/api/webAnimations.js.map +1 -1
  8. package/dist/cjs/library/backgroundScroll/test/testUtils.js +1 -2
  9. package/dist/cjs/library/backgroundScroll/test/testUtils.js.map +1 -1
  10. package/dist/cjs/library/entrance/test/testUtils.js +1 -2
  11. package/dist/cjs/library/entrance/test/testUtils.js.map +1 -1
  12. package/dist/cjs/library/ongoing/test/testUtils.js +1 -2
  13. package/dist/cjs/library/ongoing/test/testUtils.js.map +1 -1
  14. package/dist/cjs/library/scroll/test/testUtils.js +1 -2
  15. package/dist/cjs/library/scroll/test/testUtils.js.map +1 -1
  16. package/dist/cjs/playground/animationMotionBgScroll.stories.js +14 -16
  17. package/dist/cjs/playground/animationMotionBgScroll.stories.js.map +1 -1
  18. package/dist/cjs/playground/animationsMotion.stories.js +11 -12
  19. package/dist/cjs/playground/animationsMotion.stories.js.map +1 -1
  20. package/dist/cjs/playground/animationsMotionMouse.stories.js +14 -15
  21. package/dist/cjs/playground/animationsMotionMouse.stories.js.map +1 -1
  22. package/dist/cjs/playground/animationsMotionOngoing.stories.js +11 -12
  23. package/dist/cjs/playground/animationsMotionOngoing.stories.js.map +1 -1
  24. package/dist/cjs/playground/animationsMotionScroll.stories.js +12 -13
  25. package/dist/cjs/playground/animationsMotionScroll.stories.js.map +1 -1
  26. package/dist/cjs/types.js.map +1 -1
  27. package/dist/esm/api/common.js +7 -4
  28. package/dist/esm/api/common.js.map +1 -1
  29. package/dist/esm/api/cssAnimations.js +4 -4
  30. package/dist/esm/api/cssAnimations.js.map +1 -1
  31. package/dist/esm/api/webAnimations.js +6 -6
  32. package/dist/esm/api/webAnimations.js.map +1 -1
  33. package/dist/esm/library/backgroundScroll/test/testUtils.js +1 -2
  34. package/dist/esm/library/backgroundScroll/test/testUtils.js.map +1 -1
  35. package/dist/esm/library/entrance/test/testUtils.js +1 -2
  36. package/dist/esm/library/entrance/test/testUtils.js.map +1 -1
  37. package/dist/esm/library/ongoing/test/testUtils.js +1 -2
  38. package/dist/esm/library/ongoing/test/testUtils.js.map +1 -1
  39. package/dist/esm/library/scroll/test/testUtils.js +1 -2
  40. package/dist/esm/library/scroll/test/testUtils.js.map +1 -1
  41. package/dist/esm/playground/animationMotionBgScroll.stories.js +0 -2
  42. package/dist/esm/playground/animationMotionBgScroll.stories.js.map +1 -1
  43. package/dist/esm/playground/animationsMotion.stories.js +0 -1
  44. package/dist/esm/playground/animationsMotion.stories.js.map +1 -1
  45. package/dist/esm/playground/animationsMotionMouse.stories.js +0 -1
  46. package/dist/esm/playground/animationsMotionMouse.stories.js.map +1 -1
  47. package/dist/esm/playground/animationsMotionOngoing.stories.js +0 -1
  48. package/dist/esm/playground/animationsMotionOngoing.stories.js.map +1 -1
  49. package/dist/esm/playground/animationsMotionScroll.stories.js +0 -1
  50. package/dist/esm/playground/animationsMotionScroll.stories.js.map +1 -1
  51. package/dist/esm/types.js.map +1 -1
  52. package/dist/types/api/common.d.ts +4 -9
  53. package/dist/types/api/common.d.ts.map +1 -1
  54. package/dist/types/api/cssAnimations.d.ts +1 -1
  55. package/dist/types/api/cssAnimations.d.ts.map +1 -1
  56. package/dist/types/api/webAnimations.d.ts.map +1 -1
  57. package/dist/types/library/backgroundScroll/BgCloseUp.d.ts +0 -2
  58. package/dist/types/library/backgroundScroll/BgCloseUp.d.ts.map +1 -1
  59. package/dist/types/library/backgroundScroll/BgFade.d.ts +0 -1
  60. package/dist/types/library/backgroundScroll/BgFade.d.ts.map +1 -1
  61. package/dist/types/library/backgroundScroll/BgFadeBack.d.ts +0 -2
  62. package/dist/types/library/backgroundScroll/BgFadeBack.d.ts.map +1 -1
  63. package/dist/types/library/backgroundScroll/BgFake3D.d.ts +0 -2
  64. package/dist/types/library/backgroundScroll/BgFake3D.d.ts.map +1 -1
  65. package/dist/types/library/backgroundScroll/BgPan.d.ts +0 -1
  66. package/dist/types/library/backgroundScroll/BgPan.d.ts.map +1 -1
  67. package/dist/types/library/backgroundScroll/BgParallax.d.ts +0 -1
  68. package/dist/types/library/backgroundScroll/BgParallax.d.ts.map +1 -1
  69. package/dist/types/library/backgroundScroll/BgPullBack.d.ts +0 -1
  70. package/dist/types/library/backgroundScroll/BgPullBack.d.ts.map +1 -1
  71. package/dist/types/library/backgroundScroll/BgRotate.d.ts +0 -1
  72. package/dist/types/library/backgroundScroll/BgRotate.d.ts.map +1 -1
  73. package/dist/types/library/backgroundScroll/BgSkew.d.ts +0 -1
  74. package/dist/types/library/backgroundScroll/BgSkew.d.ts.map +1 -1
  75. package/dist/types/library/backgroundScroll/BgZoom.d.ts +0 -3
  76. package/dist/types/library/backgroundScroll/BgZoom.d.ts.map +1 -1
  77. package/dist/types/library/backgroundScroll/ImageParallax.d.ts +0 -1
  78. package/dist/types/library/backgroundScroll/ImageParallax.d.ts.map +1 -1
  79. package/dist/types/library/backgroundScroll/test/testUtils.d.ts.map +1 -1
  80. package/dist/types/library/entrance/ArcIn.d.ts +0 -4
  81. package/dist/types/library/entrance/ArcIn.d.ts.map +1 -1
  82. package/dist/types/library/entrance/BlurIn.d.ts +0 -4
  83. package/dist/types/library/entrance/BlurIn.d.ts.map +1 -1
  84. package/dist/types/library/entrance/BounceIn.d.ts +0 -4
  85. package/dist/types/library/entrance/BounceIn.d.ts.map +1 -1
  86. package/dist/types/library/entrance/CircleIn.d.ts +0 -4
  87. package/dist/types/library/entrance/CircleIn.d.ts.map +1 -1
  88. package/dist/types/library/entrance/CurveIn.d.ts +0 -2
  89. package/dist/types/library/entrance/CurveIn.d.ts.map +1 -1
  90. package/dist/types/library/entrance/DropIn.d.ts +0 -4
  91. package/dist/types/library/entrance/DropIn.d.ts.map +1 -1
  92. package/dist/types/library/entrance/ExpandIn.d.ts +0 -4
  93. package/dist/types/library/entrance/ExpandIn.d.ts.map +1 -1
  94. package/dist/types/library/entrance/FadeIn.d.ts +0 -2
  95. package/dist/types/library/entrance/FadeIn.d.ts.map +1 -1
  96. package/dist/types/library/entrance/FlipIn.d.ts +0 -4
  97. package/dist/types/library/entrance/FlipIn.d.ts.map +1 -1
  98. package/dist/types/library/entrance/FloatIn.d.ts +0 -2
  99. package/dist/types/library/entrance/FloatIn.d.ts.map +1 -1
  100. package/dist/types/library/entrance/FoldIn.d.ts +0 -4
  101. package/dist/types/library/entrance/FoldIn.d.ts.map +1 -1
  102. package/dist/types/library/entrance/GlideIn.d.ts +0 -2
  103. package/dist/types/library/entrance/GlideIn.d.ts.map +1 -1
  104. package/dist/types/library/entrance/GlitchIn.d.ts +0 -2
  105. package/dist/types/library/entrance/GlitchIn.d.ts.map +1 -1
  106. package/dist/types/library/entrance/GrowIn.d.ts +0 -4
  107. package/dist/types/library/entrance/GrowIn.d.ts.map +1 -1
  108. package/dist/types/library/entrance/PunchIn.d.ts +0 -4
  109. package/dist/types/library/entrance/PunchIn.d.ts.map +1 -1
  110. package/dist/types/library/entrance/RevealIn.d.ts +0 -2
  111. package/dist/types/library/entrance/RevealIn.d.ts.map +1 -1
  112. package/dist/types/library/entrance/ShapeIn.d.ts +0 -4
  113. package/dist/types/library/entrance/ShapeIn.d.ts.map +1 -1
  114. package/dist/types/library/entrance/ShuttersIn.d.ts +0 -2
  115. package/dist/types/library/entrance/ShuttersIn.d.ts.map +1 -1
  116. package/dist/types/library/entrance/SlideIn.d.ts +0 -2
  117. package/dist/types/library/entrance/SlideIn.d.ts.map +1 -1
  118. package/dist/types/library/entrance/SpinIn.d.ts +0 -4
  119. package/dist/types/library/entrance/SpinIn.d.ts.map +1 -1
  120. package/dist/types/library/entrance/TiltIn.d.ts +0 -6
  121. package/dist/types/library/entrance/TiltIn.d.ts.map +1 -1
  122. package/dist/types/library/entrance/TurnIn.d.ts +0 -4
  123. package/dist/types/library/entrance/TurnIn.d.ts.map +1 -1
  124. package/dist/types/library/entrance/WinkIn.d.ts +0 -6
  125. package/dist/types/library/entrance/WinkIn.d.ts.map +1 -1
  126. package/dist/types/library/entrance/test/testUtils.d.ts.map +1 -1
  127. package/dist/types/library/ongoing/Blink.d.ts +0 -1
  128. package/dist/types/library/ongoing/Blink.d.ts.map +1 -1
  129. package/dist/types/library/ongoing/Bounce.d.ts +0 -2
  130. package/dist/types/library/ongoing/Bounce.d.ts.map +1 -1
  131. package/dist/types/library/ongoing/Breathe.d.ts +0 -2
  132. package/dist/types/library/ongoing/Breathe.d.ts.map +1 -1
  133. package/dist/types/library/ongoing/Cross.d.ts +0 -1
  134. package/dist/types/library/ongoing/Cross.d.ts.map +1 -1
  135. package/dist/types/library/ongoing/DVD.d.ts +0 -2
  136. package/dist/types/library/ongoing/DVD.d.ts.map +1 -1
  137. package/dist/types/library/ongoing/Flash.d.ts +0 -2
  138. package/dist/types/library/ongoing/Flash.d.ts.map +1 -1
  139. package/dist/types/library/ongoing/Flip.d.ts +0 -2
  140. package/dist/types/library/ongoing/Flip.d.ts.map +1 -1
  141. package/dist/types/library/ongoing/Fold.d.ts +0 -2
  142. package/dist/types/library/ongoing/Fold.d.ts.map +1 -1
  143. package/dist/types/library/ongoing/Jello.d.ts +0 -2
  144. package/dist/types/library/ongoing/Jello.d.ts.map +1 -1
  145. package/dist/types/library/ongoing/Poke.d.ts +0 -2
  146. package/dist/types/library/ongoing/Poke.d.ts.map +1 -1
  147. package/dist/types/library/ongoing/Pulse.d.ts +0 -2
  148. package/dist/types/library/ongoing/Pulse.d.ts.map +1 -1
  149. package/dist/types/library/ongoing/Rubber.d.ts +0 -2
  150. package/dist/types/library/ongoing/Rubber.d.ts.map +1 -1
  151. package/dist/types/library/ongoing/Spin.d.ts +0 -2
  152. package/dist/types/library/ongoing/Spin.d.ts.map +1 -1
  153. package/dist/types/library/ongoing/Swing.d.ts +0 -2
  154. package/dist/types/library/ongoing/Swing.d.ts.map +1 -1
  155. package/dist/types/library/ongoing/Wiggle.d.ts +0 -2
  156. package/dist/types/library/ongoing/Wiggle.d.ts.map +1 -1
  157. package/dist/types/library/ongoing/test/testUtils.d.ts.map +1 -1
  158. package/dist/types/library/scroll/ArcScroll.d.ts +0 -1
  159. package/dist/types/library/scroll/ArcScroll.d.ts.map +1 -1
  160. package/dist/types/library/scroll/BlurScroll.d.ts +0 -1
  161. package/dist/types/library/scroll/BlurScroll.d.ts.map +1 -1
  162. package/dist/types/library/scroll/FadeScroll.d.ts +0 -1
  163. package/dist/types/library/scroll/FadeScroll.d.ts.map +1 -1
  164. package/dist/types/library/scroll/FlipScroll.d.ts +0 -1
  165. package/dist/types/library/scroll/FlipScroll.d.ts.map +1 -1
  166. package/dist/types/library/scroll/GrowScroll.d.ts +0 -1
  167. package/dist/types/library/scroll/GrowScroll.d.ts.map +1 -1
  168. package/dist/types/library/scroll/MoveScroll.d.ts +0 -1
  169. package/dist/types/library/scroll/MoveScroll.d.ts.map +1 -1
  170. package/dist/types/library/scroll/PanScroll.d.ts +0 -1
  171. package/dist/types/library/scroll/PanScroll.d.ts.map +1 -1
  172. package/dist/types/library/scroll/ParallaxScroll.d.ts +0 -1
  173. package/dist/types/library/scroll/ParallaxScroll.d.ts.map +1 -1
  174. package/dist/types/library/scroll/RevealScroll.d.ts +0 -1
  175. package/dist/types/library/scroll/RevealScroll.d.ts.map +1 -1
  176. package/dist/types/library/scroll/ShapeScroll.d.ts +0 -1
  177. package/dist/types/library/scroll/ShapeScroll.d.ts.map +1 -1
  178. package/dist/types/library/scroll/ShrinkScroll.d.ts +0 -1
  179. package/dist/types/library/scroll/ShrinkScroll.d.ts.map +1 -1
  180. package/dist/types/library/scroll/ShuttersScroll.d.ts +0 -1
  181. package/dist/types/library/scroll/ShuttersScroll.d.ts.map +1 -1
  182. package/dist/types/library/scroll/SkewPanScroll.d.ts +0 -1
  183. package/dist/types/library/scroll/SkewPanScroll.d.ts.map +1 -1
  184. package/dist/types/library/scroll/SlideScroll.d.ts +0 -1
  185. package/dist/types/library/scroll/SlideScroll.d.ts.map +1 -1
  186. package/dist/types/library/scroll/Spin3dScroll.d.ts +0 -1
  187. package/dist/types/library/scroll/Spin3dScroll.d.ts.map +1 -1
  188. package/dist/types/library/scroll/SpinScroll.d.ts +0 -1
  189. package/dist/types/library/scroll/SpinScroll.d.ts.map +1 -1
  190. package/dist/types/library/scroll/StretchScroll.d.ts +0 -2
  191. package/dist/types/library/scroll/StretchScroll.d.ts.map +1 -1
  192. package/dist/types/library/scroll/TiltScroll.d.ts +0 -2
  193. package/dist/types/library/scroll/TiltScroll.d.ts.map +1 -1
  194. package/dist/types/library/scroll/TurnScroll.d.ts +0 -1
  195. package/dist/types/library/scroll/TurnScroll.d.ts.map +1 -1
  196. package/dist/types/library/scroll/test/testUtils.d.ts.map +1 -1
  197. package/dist/types/playground/animationMotionBgScroll.stories.d.ts.map +1 -1
  198. package/dist/types/playground/animationsMotion.stories.d.ts.map +1 -1
  199. package/dist/types/playground/animationsMotionMouse.stories.d.ts.map +1 -1
  200. package/dist/types/playground/animationsMotionOngoing.stories.d.ts.map +1 -1
  201. package/dist/types/playground/animationsMotionScroll.stories.d.ts.map +1 -1
  202. package/dist/types/types.d.ts +4 -2
  203. package/dist/types/types.d.ts.map +1 -1
  204. package/package.json +2 -2
@@ -67,7 +67,6 @@ const Scroll = () => {
67
67
  }) {
68
68
  const animationInstanceParams = [el.id, {
69
69
  id: '',
70
- type: 'ScrubAnimationOptions',
71
70
  easing,
72
71
  namedEffect: {
73
72
  id: '',
@@ -134,7 +133,7 @@ const Scroll = () => {
134
133
  __self: void 0,
135
134
  __source: {
136
135
  fileName: _jsxFileName,
137
- lineNumber: 202,
136
+ lineNumber: 201,
138
137
  columnNumber: 5
139
138
  }
140
139
  }, /*#__PURE__*/_react.default.createElement("button", {
@@ -143,7 +142,7 @@ const Scroll = () => {
143
142
  __self: void 0,
144
143
  __source: {
145
144
  fileName: _jsxFileName,
146
- lineNumber: 203,
145
+ lineNumber: 202,
147
146
  columnNumber: 7
148
147
  }
149
148
  }, "Toggle Attachment"), /*#__PURE__*/_react.default.createElement("div", {
@@ -154,7 +153,7 @@ const Scroll = () => {
154
153
  __self: void 0,
155
154
  __source: {
156
155
  fileName: _jsxFileName,
157
- lineNumber: 206,
156
+ lineNumber: 205,
158
157
  columnNumber: 7
159
158
  }
160
159
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -168,7 +167,7 @@ const Scroll = () => {
168
167
  __self: void 0,
169
168
  __source: {
170
169
  fileName: _jsxFileName,
171
- lineNumber: 210,
170
+ lineNumber: 209,
172
171
  columnNumber: 9
173
172
  }
174
173
  }, "Scroll")), /*#__PURE__*/_react.default.createElement("div", {
@@ -176,7 +175,7 @@ const Scroll = () => {
176
175
  __self: void 0,
177
176
  __source: {
178
177
  fileName: _jsxFileName,
179
- lineNumber: 224,
178
+ lineNumber: 223,
180
179
  columnNumber: 7
181
180
  }
182
181
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -184,7 +183,7 @@ const Scroll = () => {
184
183
  __self: void 0,
185
184
  __source: {
186
185
  fileName: _jsxFileName,
187
- lineNumber: 225,
186
+ lineNumber: 224,
188
187
  columnNumber: 9
189
188
  }
190
189
  }, /*#__PURE__*/_react.default.createElement(_controls.NumberInput, {
@@ -197,7 +196,7 @@ const Scroll = () => {
197
196
  __self: void 0,
198
197
  __source: {
199
198
  fileName: _jsxFileName,
200
- lineNumber: 226,
199
+ lineNumber: 225,
201
200
  columnNumber: 11
202
201
  }
203
202
  }), /*#__PURE__*/_react.default.createElement(_controls.SelectInput, {
@@ -213,7 +212,7 @@ const Scroll = () => {
213
212
  __self: void 0,
214
213
  __source: {
215
214
  fileName: _jsxFileName,
216
- lineNumber: 234,
215
+ lineNumber: 233,
217
216
  columnNumber: 11
218
217
  }
219
218
  }), /*#__PURE__*/_react.default.createElement(_controls.SelectInput, {
@@ -227,7 +226,7 @@ const Scroll = () => {
227
226
  __self: void 0,
228
227
  __source: {
229
228
  fileName: _jsxFileName,
230
- lineNumber: 245,
229
+ lineNumber: 244,
231
230
  columnNumber: 11
232
231
  }
233
232
  }), /*#__PURE__*/_react.default.createElement(_controls.SelectInput, {
@@ -242,7 +241,7 @@ const Scroll = () => {
242
241
  __self: void 0,
243
242
  __source: {
244
243
  fileName: _jsxFileName,
245
- lineNumber: 257,
244
+ lineNumber: 256,
246
245
  columnNumber: 11
247
246
  }
248
247
  })), /*#__PURE__*/_react.default.createElement("div", {
@@ -250,7 +249,7 @@ const Scroll = () => {
250
249
  __self: void 0,
251
250
  __source: {
252
251
  fileName: _jsxFileName,
253
- lineNumber: 279,
252
+ lineNumber: 278,
254
253
  columnNumber: 9
255
254
  }
256
255
  }, Object.entries(schema).filter(([name]) => !['duration', 'delay', 'allowReplay'].includes(name)).map(([name, controlProps], i) => /*#__PURE__*/_react.default.createElement(_controls.Control, (0, _extends2.default)({
@@ -262,7 +261,7 @@ const Scroll = () => {
262
261
  __self: void 0,
263
262
  __source: {
264
263
  fileName: _jsxFileName,
265
- lineNumber: 307,
264
+ lineNumber: 306,
266
265
  columnNumber: 15
267
266
  }
268
267
  }))))));
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_fizban","_effectsKit","_controls","_playgroundModule","_playgroundCommon","_motion","_scroll","_jsxFileName","_default","exports","default","title","Scroll","_animations","compRef","React","useRef","stageRef","animationScene","animationGroup","scroll","schemaEditor","setSchemaEditor","useState","selectedRange","setSelectedRange","animations","Object","fromEntries","getPresets","CONFIG","schemaMapper","rangeMapper","map","preset","name","schema","range","implementedAnimations","keys","defs","filter","animationName","animName","setAnimName","rotation","setRotation","attachment","setAttachment","data","setData","mapSchemaToDefaultData","useEffect","_compRef$current","current","getAnimations","forEach","a","cancel","animateText","console","log","toggleAttachment","el","duration","delay","start","end","easing","params","animationInstanceParams","id","type","namedEffect","fill","iterations","startOffset","offset","value","endOffset","trigger","componentId","element","window","ViewTimeline","_animationGroup$curre","getWebAnimation","_scroll$current","getScrubScene","destroy","ScrollLib","root","observeViewportEntry","scenes","handleControlChange","currentData","createElement","className","styles","stage","scrollStage","ref","__self","__source","fileName","lineNumber","columnNumber","attachButton","onClick","components","style","component","background","panels","globalControls","NumberInput","label","min","max","step","onChange","event","target","valueAsNumber","SelectInput","options","mainSelect","enum","includes","controls","entries","controlProps","i","Control","_extends2","key","_e"],"sources":["../../../src/playground/animationsMotionScroll.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Scroll as ScrollLib } from 'fizban';\n\nimport { getPresets, CONFIG } from '@wix/effects-kit';\n\nimport { Control, NumberInput, SelectInput } from './controls';\nimport styles from './playground.module.scss';\nimport {\n mapSchemaToDefaultData,\n schemaMapper,\n rangeMapper,\n} from './playground-common';\nimport { AnimationGroup, getScrubScene, getWebAnimation } from '../motion';\nimport { scrollAnimations as defs } from '../library/scroll';\n\nimport type { SchemaEditor } from './playground-common';\nimport type { CSSProperties } from 'react';\nimport type { Meta } from '@wix/yoshi-storybook-dependencies';\nimport type {\n EffectConfig,\n ScrollEffectConfig,\n EffectPreset,\n OneOfScrollEffects,\n AllEffectsNames,\n OneOfEffects,\n} from '@wix/effects-kit';\nimport type {\n AnimationOptions,\n EffectScrollRange,\n ScrollAnimation,\n TriggerVariant,\n} from '../types';\n\nexport default {\n title: 'Animation Playground/Scroll',\n} as Meta;\n\nexport const Scroll: React.FC<any> = () => {\n const compRef = React.useRef<HTMLDivElement>(null);\n const stageRef = React.useRef<HTMLDivElement>(null);\n const animationScene = React.useRef<ReturnType<typeof getScrubScene>>();\n const animationGroup = React.useRef<AnimationGroup>();\n const scroll = React.useRef<typeof ScrollLib>();\n\n const [schemaEditor, setSchemaEditor] =\n React.useState<SchemaEditor>('responsive');\n\n const [selectedRange, setSelectedRange] =\n React.useState<EffectScrollRange>('in');\n\n const animations = Object.fromEntries(\n getPresets(\n CONFIG[schemaMapper[schemaEditor]][rangeMapper[selectedRange]],\n ).map((preset: EffectPreset) => [\n preset.name,\n {\n schema: preset.schema,\n range: (preset as ScrollEffectConfig<OneOfScrollEffects>).range,\n },\n ]),\n ) as Record<AllEffectsNames, ScrollEffectConfig<OneOfScrollEffects>>;\n\n const implementedAnimations = Object.keys(defs).filter(\n (animationName) => animations[animationName as AllEffectsNames],\n ) as AllEffectsNames[];\n\n const [animName, setAnimName] = React.useState<AllEffectsNames>(\n implementedAnimations[0],\n );\n\n const [rotation, setRotation] = React.useState<number>(0);\n\n const schema = (animations[animName].schema ||\n {}) as EffectConfig<OneOfEffects>['schema'];\n const [attachment, setAttachment] = React.useState<string>('scroll');\n\n const [data, setData] = React.useState<Record<string, any>>(\n mapSchemaToDefaultData(schema),\n );\n\n React.useEffect(() => {\n setData(\n mapSchemaToDefaultData(\n animations[animName as AllEffectsNames]\n .schema as EffectConfig<OneOfEffects>['schema'],\n schemaEditor,\n ),\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [schemaEditor, selectedRange]);\n\n React.useEffect(() => {\n compRef.current?.getAnimations().forEach((a) => {\n a.cancel();\n }); // removing all previously selected animations\n if (compRef.current) {\n animateText(compRef.current, animName, data);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [data, animName, rotation, animationGroup]);\n\n console.log('animation', animations[animName]);\n console.log('data', data);\n\n function toggleAttachment() {\n // Change value of CSS variable\n attachment === 'fixed' ? setAttachment('scroll') : setAttachment('fixed');\n }\n\n function animateText(\n el: HTMLElement,\n name: string,\n {\n duration = 1000,\n delay = 0,\n start = 0,\n end = 100,\n range = selectedRange,\n easing = '',\n ...params\n }: {\n duration?: number;\n delay?: number;\n start?: number;\n end?: number;\n easing?: string;\n range?: EffectScrollRange;\n },\n ) {\n const animationInstanceParams: [\n string,\n AnimationOptions,\n TriggerVariant & { element?: HTMLElement },\n ] = [\n el.id,\n {\n id: '',\n type: 'ScrubAnimationOptions',\n easing,\n namedEffect: {\n id: '',\n type: name,\n range,\n ...params,\n } as ScrollAnimation,\n fill: 'both',\n iterations: 1,\n startOffset: {\n name: 'cover',\n offset: {\n value: start,\n type: 'percentage',\n },\n },\n endOffset: {\n name: 'cover',\n offset: {\n value: end,\n type: 'percentage',\n },\n },\n },\n { trigger: 'view-progress', componentId: el.id, element: el, id: '' },\n ];\n\n if (window.ViewTimeline) {\n // Clear\n animationGroup.current?.cancel();\n // Animate\n animationGroup.current = getWebAnimation(\n ...animationInstanceParams,\n ) as AnimationGroup;\n } else {\n // Create Scene\n animationScene.current = getScrubScene(...animationInstanceParams);\n\n console.log(start, end, params);\n\n // Clear\n scroll.current?.destroy();\n\n // Animate\n scroll.current = new ScrollLib({\n root: stageRef.current,\n observeViewportEntry: false,\n // observeViewportResize: false,\n scenes: [animationScene.current],\n });\n scroll.current.start();\n }\n }\n\n function handleControlChange(name: string, value: any) {\n setData((currentData) => ({\n ...currentData,\n [name]: value,\n }));\n }\n\n return (\n <div className={`${styles.stage} ${styles.scrollStage}`} ref={stageRef}>\n <button className={`${styles.attachButton}`} onClick={toggleAttachment}>\n Toggle Attachment\n </button>\n <div\n className={styles.components}\n style={{ '--attachment': attachment } as CSSProperties}\n >\n <div\n id=\"comp1\"\n className={styles.component}\n ref={compRef}\n style={\n {\n '--comp-rotate-z': `${rotation}deg`,\n background: 'MediumVioletRed',\n } as CSSProperties\n }\n >\n Scroll\n </div>\n </div>\n <div className={styles.panels}>\n <div className={styles.globalControls}>\n <NumberInput\n label=\"Rotation\"\n value={rotation}\n min={0}\n max={360}\n step={1}\n onChange={(event) => setRotation(event.target.valueAsNumber)}\n />\n <SelectInput\n onChange={(event) => {\n const value: SchemaEditor = event.target.value;\n setSchemaEditor(value);\n // Reset \"power\" when changing editor\n // handleControlChange('power', undefined);\n }}\n value={schemaEditor}\n options={['desktop', 'mobile', 'responsive']}\n className={styles.mainSelect}\n />\n <SelectInput\n onChange={(event) => {\n const value: EffectScrollRange = event.target.value;\n setSelectedRange(value);\n }}\n value={selectedRange}\n options={\n animations[animName as AllEffectsNames]?.range\n ?.enum as EffectScrollRange[]\n }\n className={styles.mainSelect}\n />\n <SelectInput\n onChange={(event) => {\n const value: AllEffectsNames = event.target.value;\n setAnimName(value);\n setData(\n mapSchemaToDefaultData(\n (animations[value].schema ||\n {}) as EffectConfig<OneOfEffects>['schema'],\n schemaEditor,\n ),\n );\n }}\n value={animName}\n options={\n Object.keys(animations).map((name) => [\n name,\n implementedAnimations.includes(name as AllEffectsNames),\n ]) as [string, boolean][]\n }\n className={styles.mainSelect}\n />\n </div>\n <div className={styles.controls}>\n {/* <Control\n default=\"in\"\n type=\"string\"\n label=\"type\"\n enum={['in', 'out', 'continuous']}\n value={data.range}\n onChange={(_e, value) =>\n handleControlChange('range', value as EffectRangeAll)\n }\n /> */}\n {/* {data.range !== 'continuous' && (\n <Control\n default={50}\n type=\"number\"\n label={offsetType}\n min={0}\n max={100}\n step={1}\n value={data[offsetType]}\n onChange={(_e, value) => handleControlChange(offsetType, value)}\n />\n )} */}\n {Object.entries(schema)\n .filter(\n ([name]) => !['duration', 'delay', 'allowReplay'].includes(name),\n )\n .map(([name, controlProps], i) => (\n <Control\n key={`key-control-${i}`}\n {...controlProps}\n value={data[name]}\n label={name}\n onChange={(_e, value) => handleControlChange(name, value)}\n />\n ))}\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAKA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAA6D,IAAAQ,YAAA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAoB9C;EACbC,KA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AAA;MAAAkG,UAAA;MAAAC,YAAA;IAAA;EAAA,EAC3D,CACF,CACA,CACF,CACF,CAAC;AAEV,CAAC;AAACjG,OAAA,CAAAG,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_fizban","_effectsKit","_controls","_playgroundModule","_playgroundCommon","_motion","_scroll","_jsxFileName","_default","exports","default","title","Scroll","_animations","compRef","React","useRef","stageRef","animationScene","animationGroup","scroll","schemaEditor","setSchemaEditor","useState","selectedRange","setSelectedRange","animations","Object","fromEntries","getPresets","CONFIG","schemaMapper","rangeMapper","map","preset","name","schema","range","implementedAnimations","keys","defs","filter","animationName","animName","setAnimName","rotation","setRotation","attachment","setAttachment","data","setData","mapSchemaToDefaultData","useEffect","_compRef$current","current","getAnimations","forEach","a","cancel","animateText","console","log","toggleAttachment","el","duration","delay","start","end","easing","params","animationInstanceParams","id","namedEffect","type","fill","iterations","startOffset","offset","value","endOffset","trigger","componentId","element","window","ViewTimeline","_animationGroup$curre","getWebAnimation","_scroll$current","getScrubScene","destroy","ScrollLib","root","observeViewportEntry","scenes","handleControlChange","currentData","createElement","className","styles","stage","scrollStage","ref","__self","__source","fileName","lineNumber","columnNumber","attachButton","onClick","components","style","component","background","panels","globalControls","NumberInput","label","min","max","step","onChange","event","target","valueAsNumber","SelectInput","options","mainSelect","enum","includes","controls","entries","controlProps","i","Control","_extends2","key","_e"],"sources":["../../../src/playground/animationsMotionScroll.stories.tsx"],"sourcesContent":["import React from 'react';\nimport { Scroll as ScrollLib } from 'fizban';\n\nimport { getPresets, CONFIG } from '@wix/effects-kit';\n\nimport { Control, NumberInput, SelectInput } from './controls';\nimport styles from './playground.module.scss';\nimport {\n mapSchemaToDefaultData,\n schemaMapper,\n rangeMapper,\n} from './playground-common';\nimport { AnimationGroup, getScrubScene, getWebAnimation } from '../motion';\nimport { scrollAnimations as defs } from '../library/scroll';\n\nimport type { SchemaEditor } from './playground-common';\nimport type { CSSProperties } from 'react';\nimport type { Meta } from '@wix/yoshi-storybook-dependencies';\nimport type {\n EffectConfig,\n ScrollEffectConfig,\n EffectPreset,\n OneOfScrollEffects,\n AllEffectsNames,\n OneOfEffects,\n} from '@wix/effects-kit';\nimport type {\n AnimationOptions,\n EffectScrollRange,\n ScrollAnimation,\n TriggerVariant,\n} from '../types';\n\nexport default {\n title: 'Animation Playground/Scroll',\n} as Meta;\n\nexport const Scroll: React.FC<any> = () => {\n const compRef = React.useRef<HTMLDivElement>(null);\n const stageRef = React.useRef<HTMLDivElement>(null);\n const animationScene = React.useRef<ReturnType<typeof getScrubScene>>();\n const animationGroup = React.useRef<AnimationGroup>();\n const scroll = React.useRef<typeof ScrollLib>();\n\n const [schemaEditor, setSchemaEditor] =\n React.useState<SchemaEditor>('responsive');\n\n const [selectedRange, setSelectedRange] =\n React.useState<EffectScrollRange>('in');\n\n const animations = Object.fromEntries(\n getPresets(\n CONFIG[schemaMapper[schemaEditor]][rangeMapper[selectedRange]],\n ).map((preset: EffectPreset) => [\n preset.name,\n {\n schema: preset.schema,\n range: (preset as ScrollEffectConfig<OneOfScrollEffects>).range,\n },\n ]),\n ) as Record<AllEffectsNames, ScrollEffectConfig<OneOfScrollEffects>>;\n\n const implementedAnimations = Object.keys(defs).filter(\n (animationName) => animations[animationName as AllEffectsNames],\n ) as AllEffectsNames[];\n\n const [animName, setAnimName] = React.useState<AllEffectsNames>(\n implementedAnimations[0],\n );\n\n const [rotation, setRotation] = React.useState<number>(0);\n\n const schema = (animations[animName].schema ||\n {}) as EffectConfig<OneOfEffects>['schema'];\n const [attachment, setAttachment] = React.useState<string>('scroll');\n\n const [data, setData] = React.useState<Record<string, any>>(\n mapSchemaToDefaultData(schema),\n );\n\n React.useEffect(() => {\n setData(\n mapSchemaToDefaultData(\n animations[animName as AllEffectsNames]\n .schema as EffectConfig<OneOfEffects>['schema'],\n schemaEditor,\n ),\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [schemaEditor, selectedRange]);\n\n React.useEffect(() => {\n compRef.current?.getAnimations().forEach((a) => {\n a.cancel();\n }); // removing all previously selected animations\n if (compRef.current) {\n animateText(compRef.current, animName, data);\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [data, animName, rotation, animationGroup]);\n\n console.log('animation', animations[animName]);\n console.log('data', data);\n\n function toggleAttachment() {\n // Change value of CSS variable\n attachment === 'fixed' ? setAttachment('scroll') : setAttachment('fixed');\n }\n\n function animateText(\n el: HTMLElement,\n name: string,\n {\n duration = 1000,\n delay = 0,\n start = 0,\n end = 100,\n range = selectedRange,\n easing = '',\n ...params\n }: {\n duration?: number;\n delay?: number;\n start?: number;\n end?: number;\n easing?: string;\n range?: EffectScrollRange;\n },\n ) {\n const animationInstanceParams: [\n string,\n AnimationOptions,\n TriggerVariant & { element?: HTMLElement },\n ] = [\n el.id,\n {\n id: '',\n easing,\n namedEffect: {\n id: '',\n type: name,\n range,\n ...params,\n } as ScrollAnimation,\n fill: 'both',\n iterations: 1,\n startOffset: {\n name: 'cover',\n offset: {\n value: start,\n type: 'percentage',\n },\n },\n endOffset: {\n name: 'cover',\n offset: {\n value: end,\n type: 'percentage',\n },\n },\n },\n { trigger: 'view-progress', componentId: el.id, element: el, id: '' },\n ];\n\n if (window.ViewTimeline) {\n // Clear\n animationGroup.current?.cancel();\n // Animate\n animationGroup.current = getWebAnimation(\n ...animationInstanceParams,\n ) as AnimationGroup;\n } else {\n // Create Scene\n animationScene.current = getScrubScene(...animationInstanceParams);\n\n console.log(start, end, params);\n\n // Clear\n scroll.current?.destroy();\n\n // Animate\n scroll.current = new ScrollLib({\n root: stageRef.current,\n observeViewportEntry: false,\n // observeViewportResize: false,\n scenes: [animationScene.current],\n });\n scroll.current.start();\n }\n }\n\n function handleControlChange(name: string, value: any) {\n setData((currentData) => ({\n ...currentData,\n [name]: value,\n }));\n }\n\n return (\n <div className={`${styles.stage} ${styles.scrollStage}`} ref={stageRef}>\n <button className={`${styles.attachButton}`} onClick={toggleAttachment}>\n Toggle Attachment\n </button>\n <div\n className={styles.components}\n style={{ '--attachment': attachment } as CSSProperties}\n >\n <div\n id=\"comp1\"\n className={styles.component}\n ref={compRef}\n style={\n {\n '--comp-rotate-z': `${rotation}deg`,\n background: 'MediumVioletRed',\n } as CSSProperties\n }\n >\n Scroll\n </div>\n </div>\n <div className={styles.panels}>\n <div className={styles.globalControls}>\n <NumberInput\n label=\"Rotation\"\n value={rotation}\n min={0}\n max={360}\n step={1}\n onChange={(event) => setRotation(event.target.valueAsNumber)}\n />\n <SelectInput\n onChange={(event) => {\n const value: SchemaEditor = event.target.value;\n setSchemaEditor(value);\n // Reset \"power\" when changing editor\n // handleControlChange('power', undefined);\n }}\n value={schemaEditor}\n options={['desktop', 'mobile', 'responsive']}\n className={styles.mainSelect}\n />\n <SelectInput\n onChange={(event) => {\n const value: EffectScrollRange = event.target.value;\n setSelectedRange(value);\n }}\n value={selectedRange}\n options={\n animations[animName as AllEffectsNames]?.range\n ?.enum as EffectScrollRange[]\n }\n className={styles.mainSelect}\n />\n <SelectInput\n onChange={(event) => {\n const value: AllEffectsNames = event.target.value;\n setAnimName(value);\n setData(\n mapSchemaToDefaultData(\n (animations[value].schema ||\n {}) as EffectConfig<OneOfEffects>['schema'],\n schemaEditor,\n ),\n );\n }}\n value={animName}\n options={\n Object.keys(animations).map((name) => [\n name,\n implementedAnimations.includes(name as AllEffectsNames),\n ]) as [string, boolean][]\n }\n className={styles.mainSelect}\n />\n </div>\n <div className={styles.controls}>\n {/* <Control\n default=\"in\"\n type=\"string\"\n label=\"type\"\n enum={['in', 'out', 'continuous']}\n value={data.range}\n onChange={(_e, value) =>\n handleControlChange('range', value as EffectRangeAll)\n }\n /> */}\n {/* {data.range !== 'continuous' && (\n <Control\n default={50}\n type=\"number\"\n label={offsetType}\n min={0}\n max={100}\n step={1}\n value={data[offsetType]}\n onChange={(_e, value) => handleControlChange(offsetType, value)}\n />\n )} */}\n {Object.entries(schema)\n .filter(\n ([name]) => !['duration', 'delay', 'allowReplay'].includes(name),\n )\n .map(([name, controlProps], i) => (\n <Control\n key={`key-control-${i}`}\n {...controlProps}\n value={data[name]}\n label={name}\n onChange={(_e, value) => handleControlChange(name, value)}\n />\n ))}\n </div>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAKA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAA6D,IAAAQ,YAAA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAoB9C;EACbC,KAAK,EAAE;AACT,CAAC;AAEM,MAAMC,MAAqB,GAAGA,CAAA,KAAM;EAAA,IAAAC,WAAA;EACzC,MAAMC,OAAO,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,QAAQ,GAAGF,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EACnD,MAAME,cAAc,GAAGH,cAAK,CAACC,MAAM,CAAmC,CAAC;EACvE,MAAMG,cAAc,GAAGJ,cAAK,CAACC,MAAM,CAAiB,CAAC;EACrD,MAAMI,MAAM,GAAGL,cAAK,CAACC,MAAM,CAAmB,CAAC;EAE/C,MAAM,CAACK,YAAY,EAAEC,eAAe,CAAC,GACnCP,cAAK,CAACQ,QAAQ,CAAe,YAAY,CAAC;EAE5C,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GACrCV,cAAK,CAACQ,QAAQ,CAAoB,IAAI,CAAC;EAEzC,MAAMG,UAAU,GAAGC,MAAM,CAACC,WAAW,CACnC,IAAAC,sBAAU,EACRC,kBAAM,CAACC,8BAAY,CAACV,YAAY,CAAC,CAAC,CAACW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AAO,EAAE,aAAa,CAAC,CAAC6F,QAAQ,CAAC7F,IAAI,CACjE,CAAC,CACAF,GAAG,CAAC,CAAC,CAACE,IAAI,EAAEgG,YAAY,CAAC,EAAEC,CAAC,kBAC3BvI,MAAA,CAAAa,OAAA,CAAAsF,aAAA,CAAC9F,SAAA,CAAAmI,OAAO,MAAAC,SAAA,CAAA5H,OAAA;IACN6H,GAAG,EAAE,eAAeH,CAAC;EAAG,GACpBD,YAAY;IAChBrD,KAAK,EAAE7B,IAAI,CAACd,IAAI,CAAE;IAClBiF,KAAK,EAAEjF,IAAK;IACZqF,QAAQ,EAAEA,CAACgB,EAAE,EAAE1D,KAAK,KAAKgB,mBAAmB,CAAC3D,IAAI,EAAE2C,KAAK,CAAE;IAAAwB,MAAA;IAAAC,QAAA;MAAAC,QAAA,EAAAjG,YAAA;MAAAkG,UAAA;MAAAC,YAAA;IAAA;EAAA,EAC3D,CACF,CACA,CACF,CACF,CAAC;AAEV,CAAC;AAACjG,OAAA,CAAAG,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["type LengthUnit = 'px' | 'em' | 'rem' | 'vh' | 'vw' | 'vmin' | 'vmax';\n\nexport declare type Length = {\n value: number;\n type: LengthUnit;\n};\n\nexport declare type Percentage = {\n value: number;\n type: 'percentage';\n};\n\nexport declare type LengthPercentage = Length | Percentage;\n\nexport declare type UnitLengthPercentage = LengthPercentage;\n\nexport type Point = [number, number];\n\nexport type EffectNineDirections =\n | 'right'\n | 'top-right'\n | 'top'\n | 'top-left'\n | 'left'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right'\n | 'center';\n\nexport type EffectScaleDirection = 'up' | 'down';\n\ndeclare class ViewTimeline {\n constructor(options: { subject: HTMLElement });\n}\n\ndeclare global {\n interface Window {\n ViewTimeline: ViewTimeline;\n }\n}\n\nexport type AnimationFillMode = 'none' | 'backwards' | 'forwards' | 'both';\n\nexport type BaseDataItemLike<Type extends string = string> = {\n id?: string;\n type: Type;\n};\n\nexport type EffectTwoSides = 'left' | 'right';\n\nexport type EffectFourDirections = 'top' | 'right' | 'bottom' | 'left';\nexport type EffectFourCorners =\n | 'top-right'\n | 'top-left'\n | 'bottom-right'\n | 'bottom-left';\nexport type EffectEightDirections = EffectFourDirections | EffectFourCorners;\nexport type EffectPower = 'soft' | 'medium' | 'hard';\nexport type EffectScrollRange = 'in' | 'out' | 'continuous';\n\nexport type FadeIn = BaseDataItemLike<'FadeIn'>;\nexport type ArcIn = BaseDataItemLike<'ArcIn'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n};\nexport type CurveIn = BaseDataItemLike<'CurveIn'> & {\n direction: EffectTwoSides;\n};\nexport type DropIn = BaseDataItemLike<'DropIn'> & {\n power?: EffectPower;\n initialScale?: number;\n};\nexport type ExpandIn = BaseDataItemLike<'ExpandIn'> & {\n power?: EffectPower;\n direction: EffectEightDirections | 'center';\n initialScale?: number;\n};\nexport type FlipIn = BaseDataItemLike<'FlipIn'> & {\n power?: EffectPower;\n direction: EffectFourDirections;\n initialRotate?: number;\n};\nexport type FloatIn = BaseDataItemLike<'FloatIn'> & {\n direction: EffectFourDirections;\n};\nexport type FoldIn = BaseDataItemLike<'FoldIn'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n initialRotate?: number;\n};\nexport type SlideIn = BaseDataItemLike<'SlideIn'> & {\n power?: EffectPower;\n direction: EffectFourDirections;\n initialTranslate?: number;\n};\nexport type SpinIn = BaseDataItemLike<'SpinIn'> & {\n spins: number;\n direction: 'clockwise' | 'counter-clockwise';\n power?: EffectPower;\n initialScale?: number;\n};\nexport type BounceIn = BaseDataItemLike<'BounceIn'> & {\n direction: EffectFourDirections | 'center';\n power?: EffectPower;\n distanceFactor?: number;\n};\nexport type PunchIn = BaseDataItemLike<'PunchIn'> & {\n direction: EffectFourCorners | 'center';\n power?: EffectPower;\n};\nexport type GlideIn = BaseDataItemLike<'GlideIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n startFromOffScreen?: boolean;\n};\nexport type GlitchIn = BaseDataItemLike<'GlitchIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n startFromOffScreen?: boolean;\n};\nexport type TurnIn = BaseDataItemLike<'TurnIn'> & {\n direction: EffectFourCorners;\n power?: EffectPower;\n};\nexport type CircleIn = BaseDataItemLike<'CircleIn'> & {\n direction: EffectTwoSides;\n};\nexport type WinkIn = BaseDataItemLike<'WinkIn'> & {\n direction: 'vertical' | 'horizontal';\n};\nexport type TiltIn = BaseDataItemLike<'TiltIn'> & {\n direction: EffectTwoSides;\n};\nexport type ShapeIn = BaseDataItemLike<'ShapeIn'> & {\n shape: 'circle' | 'ellipse' | 'rectangle' | 'diamond' | 'window';\n direction: EffectEightDirections | 'center';\n};\n\nexport type ShuttersIn = BaseDataItemLike<'ShuttersIn'> & {\n direction: EffectFourDirections;\n shutters: number;\n staggered: boolean;\n power?: EffectPower;\n};\nexport type GrowIn = BaseDataItemLike<'GrowIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n initialScale?: number;\n};\nexport type RevealIn = BaseDataItemLike<'RevealIn'> & {\n direction: EffectFourDirections;\n};\nexport type BlurIn = BaseDataItemLike<'BlurIn'> & {\n blur?: number;\n power?: EffectPower;\n};\n\nexport type AnimationOptionsTypes = {\n time: TimeAnimationOptions & AnimationExtraOptions;\n scrub: ScrubAnimationOptions & AnimationExtraOptions;\n};\n\nexport type AnimationEffectAPI<Enum extends keyof AnimationOptionsTypes> = {\n web: (\n animationOptions: AnimationOptionsTypes[Enum],\n dom?: DomApi,\n options?: Record<string, any>,\n ) => AnimationData[];\n getNames: (animationOptions: AnimationOptionsTypes[Enum]) => string[];\n style?: (options: AnimationOptionsTypes[Enum]) => AnimationData[];\n prepare?: (options: AnimationOptionsTypes[Enum], dom?: DomApi) => void;\n};\n\nexport type WebAnimationEffectFactory<\n Enum extends keyof AnimationOptionsTypes,\n> = (\n animationOptions: AnimationOptionsTypes[Enum],\n dom?: DomApi,\n options?: Record<string, any>,\n) => AnimationData[];\n\nexport type EntranceAnimation =\n | FadeIn\n | ArcIn\n | CurveIn\n | DropIn\n | ExpandIn\n | FlipIn\n | FloatIn\n | FoldIn\n | SlideIn\n | SpinIn\n | BounceIn\n | PunchIn\n | GlideIn\n | GlitchIn\n | TurnIn\n | CircleIn\n | WinkIn\n | TiltIn\n | ShapeIn\n | ShuttersIn\n | GrowIn\n | RevealIn\n | BlurIn;\nexport type EntranceAnimations = Record<\n EntranceAnimation['type'],\n AnimationEffectAPI<'time'>\n>;\n\nexport type Breathe = BaseDataItemLike<'Breathe'> & {\n direction: 'vertical' | 'horizontal' | 'center';\n distance: UnitLengthPercentage;\n};\nexport type Pulse = BaseDataItemLike<'Pulse'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Spin = BaseDataItemLike<'Spin'> & {\n direction: 'clockwise' | 'counter-clockwise';\n power?: EffectPower;\n};\nexport type Poke = BaseDataItemLike<'Poke'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n intensity?: number;\n};\nexport type Flash = BaseDataItemLike<'Flash'>;\nexport type Swing = BaseDataItemLike<'Swing'> & {\n power?: EffectPower;\n swing?: number;\n direction?: EffectFourDirections;\n};\nexport type Flip = BaseDataItemLike<'Flip'> & {\n direction: 'vertical' | 'horizontal';\n power?: EffectPower;\n};\nexport type Rubber = BaseDataItemLike<'Rubber'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Fold = BaseDataItemLike<'Fold'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n angle?: number;\n};\nexport type Jello = BaseDataItemLike<'Jello'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Wiggle = BaseDataItemLike<'Wiggle'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Bounce = BaseDataItemLike<'Bounce'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Cross = BaseDataItemLike<'Cross'> & {\n direction: EffectEightDirections;\n};\nexport type DVD = BaseDataItemLike<'DVD'> & {\n power?: EffectPower;\n};\n\nexport type Blink = BaseDataItemLike<'Blink'> & {\n power?: EffectPower;\n scale?: number;\n distance?: UnitLengthPercentage;\n};\n\nexport type OngoingAnimation =\n | Breathe\n | Blink\n | Pulse\n | Spin\n | Poke\n | Flash\n | Swing\n | Flip\n | Rubber\n | Fold\n | Jello\n | Wiggle\n | Bounce\n | Cross\n | DVD;\nexport type OngoingAnimations = Record<\n OngoingAnimation['type'],\n AnimationEffectAPI<'time'>\n>;\n\nexport type ArcScroll = BaseDataItemLike<'ArcScroll'> & {\n direction: 'vertical' | 'horizontal';\n range?: EffectScrollRange;\n};\nexport type BlurScroll = BaseDataItemLike<'BlurScroll'> & {\n power?: EffectPower;\n range?: EffectScrollRange;\n blur?: number;\n};\nexport type FadeScroll = BaseDataItemLike<'FadeScroll'> & {\n range: EffectScrollRange;\n opacity: number;\n};\nexport type FlipScroll = BaseDataItemLike<'FlipScroll'> & {\n direction: 'vertical' | 'horizontal';\n power?: EffectPower;\n range?: EffectScrollRange;\n rotate?: number;\n};\nexport type GrowScroll = BaseDataItemLike<'GrowScroll'> & {\n direction: EffectNineDirections;\n power?: EffectPower;\n range?: EffectScrollRange;\n scale?: number;\n speed?: number;\n};\nexport type MoveScroll = BaseDataItemLike<'MoveScroll'> & {\n angle: number;\n power?: EffectPower;\n range?: EffectScrollRange;\n distance?: UnitLengthPercentage;\n};\nexport type PanScroll = BaseDataItemLike<'PanScroll'> & {\n direction: EffectTwoSides;\n distance: UnitLengthPercentage;\n startFromOffScreen: boolean;\n range?: EffectScrollRange;\n};\nexport type ParallaxScroll = BaseDataItemLike<'ParallaxScroll'> & {\n speed: number;\n range?: EffectScrollRange;\n};\nexport type RevealScroll = BaseDataItemLike<'RevealScroll'> & {\n direction: EffectFourDirections;\n range?: EffectScrollRange;\n};\nexport type ShapeScroll = BaseDataItemLike<'ShapeScroll'> & {\n shape: 'circle' | 'ellipse' | 'rectangle' | 'diamond' | 'window';\n range?: EffectScrollRange;\n power?: EffectPower;\n intensity?: number;\n};\nexport type ShrinkScroll = BaseDataItemLike<'ShrinkScroll'> & {\n direction: EffectNineDirections;\n power?: EffectPower;\n range?: EffectScrollRange;\n scale?: number;\n speed?: number;\n};\nexport type ShuttersScroll = BaseDataItemLike<'ShuttersScroll'> & {\n direction: EffectFourDirections;\n shutters: number;\n staggered: boolean;\n range?: EffectScrollRange;\n};\nexport type SkewPanScroll = BaseDataItemLike<'SkewPanScroll'> & {\n direction: EffectTwoSides;\n range?: EffectScrollRange;\n power?: EffectPower;\n skew?: number;\n};\nexport type SlideScroll = BaseDataItemLike<'SlideScroll'> & {\n direction: EffectFourDirections;\n range?: EffectScrollRange;\n};\nexport type Spin3dScroll = BaseDataItemLike<'Spin3dScroll'> & {\n range?: EffectScrollRange;\n power?: EffectPower;\n rotate?: number;\n speed?: number;\n};\nexport type SpinScroll = BaseDataItemLike<'SpinScroll'> & {\n direction: 'clockwise' | 'counter-clockwise';\n spins: number;\n range?: EffectScrollRange;\n power?: EffectPower;\n scale?: number;\n};\nexport type StretchScroll = BaseDataItemLike<'StretchScroll'> & {\n power?: EffectPower;\n range?: EffectScrollRange;\n stretch?: number;\n};\nexport type TiltScroll = BaseDataItemLike<'TiltScroll'> & {\n direction: EffectTwoSides;\n range?: EffectScrollRange;\n power?: EffectPower;\n distance?: number;\n};\nexport type TurnScroll = BaseDataItemLike<'TurnScroll'> & {\n direction: EffectTwoSides;\n spin: 'clockwise' | 'counter-clockwise';\n range?: EffectScrollRange;\n power?: EffectPower;\n scale?: number;\n};\n\nexport type ScrollAnimation =\n | ArcScroll\n | BlurScroll\n | FadeScroll\n | FlipScroll\n | GrowScroll\n | MoveScroll\n | PanScroll\n | ParallaxScroll\n | RevealScroll\n | ShapeScroll\n | ShuttersScroll\n | ShrinkScroll\n | SkewPanScroll\n | SlideScroll\n | Spin3dScroll\n | SpinScroll\n | StretchScroll\n | TiltScroll\n | TurnScroll;\nexport type ScrollAnimations = Record<\n ScrollAnimation['type'],\n WebAnimationEffectFactory<'scrub'>\n>;\n\nexport type BgCloseUp = BaseDataItemLike<'BgCloseUp'> & {\n scale?: number;\n};\nexport type BgFade = BaseDataItemLike<'BgFade'> & {\n range: 'in' | 'out';\n};\nexport type BgFadeBack = BaseDataItemLike<'BgFadeBack'> & {\n scale?: number;\n};\nexport type BgFake3D = BaseDataItemLike<'BgFake3D'> & {\n stretch?: number;\n zoom?: number;\n};\nexport type BgPan = BaseDataItemLike<'BgPan'> & {\n direction: 'left' | 'right';\n speed?: number;\n};\nexport type BgParallax = BaseDataItemLike<'BgParallax'> & {\n speed?: number;\n};\nexport type BgPullBack = BaseDataItemLike<'BgPullBack'> & {\n scale?: number;\n};\nexport type BgReveal = BaseDataItemLike<'BgReveal'>;\nexport type BgRotate = BaseDataItemLike<'BgRotate'> & {\n direction?: 'ccw' | 'cw';\n angle?: number;\n};\nexport type BgSkew = BaseDataItemLike<'BgSkew'> & {\n direction?: 'ccw' | 'cw';\n angle?: number;\n};\nexport type BgZoom = BaseDataItemLike<'BgZoom'> & {\n direction: 'in' | 'out';\n zoom?: number;\n};\nexport type ImageParallax = BaseDataItemLike<'ImageParallax'> & {\n reverse?: boolean;\n speed?: number;\n isPage?: boolean;\n};\n\nexport type BackgroundScrollAnimation =\n | BgCloseUp\n | BgFade\n | BgFadeBack\n | BgFake3D\n | BgPan\n | BgParallax\n | BgPullBack\n | BgReveal\n | BgRotate\n | BgSkew\n | BgZoom\n | ImageParallax;\n\nexport type BackgroundScrollAnimations = Record<\n BackgroundScrollAnimation['type'],\n WebAnimationEffectFactory<'scrub'>\n>;\n\ntype MouseEffectBase = {\n inverted?: boolean;\n};\n\ntype MouseEffectAxis = 'both' | 'horizontal' | 'vertical';\n\nexport type MousePivotAxis =\n | 'top'\n | 'bottom'\n | 'right'\n | 'left'\n | 'center-horizontal'\n | 'center-vertical';\n\nexport type AiryMouse = BaseDataItemLike<'AiryMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n angle?: number;\n power?: EffectPower;\n };\nexport type BlobMouse = BaseDataItemLike<'BlobMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n scale?: number;\n power?: EffectPower;\n };\nexport type BlurMouse = BaseDataItemLike<'BlurMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n scale?: number;\n blur?: number;\n perspective?: number;\n power?: EffectPower;\n };\nexport type BounceMouse = BaseDataItemLike<'BounceMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type ScaleMouse = BaseDataItemLike<'ScaleMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n scale?: number;\n power?: EffectPower;\n scaleDirection: EffectScaleDirection;\n };\nexport type SkewMouse = BaseDataItemLike<'SkewMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type SpinMouse = BaseDataItemLike<'SpinMouse'> &\n MouseEffectBase & {\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type SwivelMouse = BaseDataItemLike<'SwivelMouse'> &\n MouseEffectBase & {\n angle?: number;\n perspective?: number;\n pivotAxis?: MousePivotAxis;\n power?: EffectPower;\n };\nexport type Tilt3DMouse = BaseDataItemLike<'Tilt3DMouse'> &\n MouseEffectBase & {\n angle?: number;\n perspective?: number;\n power?: EffectPower;\n };\nexport type Track3DMouse = BaseDataItemLike<'Track3DMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n axis?: MouseEffectAxis;\n perspective?: number;\n power?: EffectPower;\n };\nexport type TrackMouse = BaseDataItemLike<'TrackMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\n\nexport type CustomMouse = BaseDataItemLike<'CustomMouse'>;\n\nexport type Progress = {\n x: number;\n y: number;\n v?: { x: number; y: number };\n active?: boolean;\n};\nexport interface MouseAnimationInstance {\n target: HTMLElement;\n play: () => void;\n progress: (progress: Progress) => void;\n cancel: () => void;\n}\n\nexport interface CustomMouseAnimationInstance extends MouseAnimationInstance {\n getProgress: () => Progress;\n}\n\nexport type MouseAnimationFactory = (\n element: HTMLElement,\n) => MouseAnimationInstance;\n\nexport type MouseAnimationFactoryCreate = (\n options: ScrubAnimationOptions,\n dom?: DomApi,\n) => MouseAnimationFactory;\n\nexport type MouseAnimation =\n | AiryMouse\n | BlobMouse\n | BlurMouse\n | BounceMouse\n | CustomMouse\n | ScaleMouse\n | SkewMouse\n | SpinMouse\n | SwivelMouse\n | Tilt3DMouse\n | Track3DMouse\n | TrackMouse;\nexport type MouseAnimations = Record<\n MouseAnimation['type'],\n MouseAnimationFactoryCreate\n>;\n\nexport type NamedEffect =\n | EntranceAnimation\n | OngoingAnimation\n | ScrollAnimation\n | MouseAnimation\n | BackgroundScrollAnimation;\n\nexport type CustomEffect =\n | {\n ranges: { name: string; min: number; max: number; step?: number }[];\n }\n | ((element: Element | null, progress: number | null) => void);\n\nexport type AnimationExtraOptions = {\n effectId?: string;\n effect?: (\n progress: () => number | { x: number | undefined; y: number | undefined },\n ) => void;\n};\n\nexport type AnimationOptions = (TimeAnimationOptions | ScrubAnimationOptions) &\n AnimationExtraOptions;\n\nexport type MotionAnimationOptions<T extends keyof AnimationOptionsTypes> =\n AnimationOptionsTypes[T];\n\nexport type MeasureCallback = (\n fn: (target: HTMLElement | null) => void,\n) => void;\nexport type DomApi = { measure: MeasureCallback; mutate: MeasureCallback };\n\nexport type NamedEffectFunction = (\n options: AnimationOptions,\n domApi?: DomApi | undefined,\n config?: Record<string, any>,\n) => AnimationData[];\n\nexport type ScrubTransitionEasing =\n | 'linear'\n | 'hardBackOut'\n | 'easeOut'\n | 'elastic'\n | 'bounce';\n\nexport type RangeOffset = {\n name?:\n | 'entry'\n | 'exit'\n | 'contain'\n | 'cover'\n | 'entry-crossing'\n | 'exit-crossing';\n offset?: LengthPercentage;\n};\n\nexport type MotionKeyframeEffect = BaseDataItemLike<'KeyframeEffect'> & {\n name: string;\n keyframes: Keyframe[];\n};\n\nexport type TimeAnimationOptions = BaseDataItemLike<'TimeAnimationOptions'> & {\n keyframeEffect?: MotionKeyframeEffect;\n namedEffect?: NamedEffect;\n customEffect?: CustomEffect;\n duration?: number;\n delay?: number;\n endDelay?: number;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: AnimationFillMode;\n reversed?: boolean;\n};\n\ntype ScrubAnimationDataBase = BaseDataItemLike<'ScrubAnimationOptions'> & {\n keyframeEffect?: MotionKeyframeEffect;\n namedEffect?: NamedEffect;\n customEffect?: CustomEffect;\n startOffset?: RangeOffset;\n endOffset?: RangeOffset;\n playbackRate?: number;\n easing?: string;\n iterations?: number;\n fill?: AnimationFillMode;\n alternate?: boolean;\n reversed?: boolean;\n transitionDuration?: number;\n transitionDelay?: number;\n transitionEasing?: ScrubTransitionEasing;\n centeredToTarget?: boolean;\n};\n\nexport type ScrubAnimationOptions = ScrubAnimationDataBase & {\n duration?: LengthPercentage;\n};\n\ntype AnimationDataExtra = {\n name?: string; // TODO: need to be added to all animations and then be made required\n keyframes: Record<string, string | number | undefined>[];\n custom?: Record<string, string | number | undefined>;\n composite?: CompositeOperation;\n part?: string;\n timing?: Partial<EffectTiming>;\n};\n\nexport type AnimationDataForScrub = ScrubAnimationDataBase & {\n duration?: LengthPercentage | number;\n startOffsetAdd?: string;\n endOffsetAdd?: string;\n};\n\nexport type AnimationData = (TimeAnimationOptions | AnimationDataForScrub) &\n AnimationDataExtra;\n\n// TODO: need it?\nexport type AnimationProperties = {\n groups?: string[];\n schema: { [key: string]: any };\n};\n\nexport type TriggerVariant = {\n id: string;\n trigger: 'view-progress' | 'pointer-move';\n componentId: string;\n};\n\nexport type AnimationGroupOptions = AnimationOptions & {\n trigger?: Partial<TriggerVariant> | undefined;\n startOffsetAdd?: string | undefined;\n endOffsetAdd?: string | undefined;\n measured?: Promise<void>;\n};\n\nexport type Shape = 'ellipse' | 'circle' | 'rectangle' | 'diamond' | 'window';\n\nexport interface ScrubScrollScene {\n start: RangeOffset;\n end: RangeOffset;\n viewSource: HTMLElement;\n ready: Promise<void>;\n getProgress(): number;\n effect(__: any, p: number): void;\n disabled: boolean;\n destroy(): void;\n groupId?: string;\n}\n\nexport interface ScrubPointerScene {\n target?: HTMLElement;\n centeredToTarget?: boolean;\n transitionDuration?: number;\n transitionEasing?: ScrubTransitionEasing;\n getProgress(): Progress;\n effect(p: Progress): void;\n disabled: boolean;\n destroy(): void;\n allowActiveEvent?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["type LengthUnit = 'px' | 'em' | 'rem' | 'vh' | 'vw' | 'vmin' | 'vmax';\n\nexport declare type Length = {\n value: number;\n type: LengthUnit;\n};\n\nexport declare type Percentage = {\n value: number;\n type: 'percentage';\n};\n\nexport declare type LengthPercentage = Length | Percentage;\n\nexport declare type UnitLengthPercentage = LengthPercentage;\n\nexport type Point = [number, number];\n\nexport type EffectNineDirections =\n | 'right'\n | 'top-right'\n | 'top'\n | 'top-left'\n | 'left'\n | 'bottom-left'\n | 'bottom'\n | 'bottom-right'\n | 'center';\n\nexport type EffectScaleDirection = 'up' | 'down';\n\ndeclare class ViewTimeline {\n constructor(options: { subject: HTMLElement });\n}\n\ndeclare global {\n interface Window {\n ViewTimeline: ViewTimeline;\n }\n}\n\nexport type AnimationFillMode = 'none' | 'backwards' | 'forwards' | 'both';\n\nexport type BaseDataItemLike<Type extends string = string> = {\n id?: string;\n type: Type;\n};\n\nexport type EffectTwoSides = 'left' | 'right';\n\nexport type EffectFourDirections = 'top' | 'right' | 'bottom' | 'left';\nexport type EffectFourCorners =\n | 'top-right'\n | 'top-left'\n | 'bottom-right'\n | 'bottom-left';\nexport type EffectEightDirections = EffectFourDirections | EffectFourCorners;\nexport type EffectPower = 'soft' | 'medium' | 'hard';\nexport type EffectScrollRange = 'in' | 'out' | 'continuous';\n\nexport type FadeIn = BaseDataItemLike<'FadeIn'>;\nexport type ArcIn = BaseDataItemLike<'ArcIn'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n};\nexport type CurveIn = BaseDataItemLike<'CurveIn'> & {\n direction: EffectTwoSides;\n};\nexport type DropIn = BaseDataItemLike<'DropIn'> & {\n power?: EffectPower;\n initialScale?: number;\n};\nexport type ExpandIn = BaseDataItemLike<'ExpandIn'> & {\n power?: EffectPower;\n direction: EffectEightDirections | 'center';\n initialScale?: number;\n};\nexport type FlipIn = BaseDataItemLike<'FlipIn'> & {\n power?: EffectPower;\n direction: EffectFourDirections;\n initialRotate?: number;\n};\nexport type FloatIn = BaseDataItemLike<'FloatIn'> & {\n direction: EffectFourDirections;\n};\nexport type FoldIn = BaseDataItemLike<'FoldIn'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n initialRotate?: number;\n};\nexport type SlideIn = BaseDataItemLike<'SlideIn'> & {\n power?: EffectPower;\n direction: EffectFourDirections;\n initialTranslate?: number;\n};\nexport type SpinIn = BaseDataItemLike<'SpinIn'> & {\n spins: number;\n direction: 'clockwise' | 'counter-clockwise';\n power?: EffectPower;\n initialScale?: number;\n};\nexport type BounceIn = BaseDataItemLike<'BounceIn'> & {\n direction: EffectFourDirections | 'center';\n power?: EffectPower;\n distanceFactor?: number;\n};\nexport type PunchIn = BaseDataItemLike<'PunchIn'> & {\n direction: EffectFourCorners | 'center';\n power?: EffectPower;\n};\nexport type GlideIn = BaseDataItemLike<'GlideIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n startFromOffScreen?: boolean;\n};\nexport type GlitchIn = BaseDataItemLike<'GlitchIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n startFromOffScreen?: boolean;\n};\nexport type TurnIn = BaseDataItemLike<'TurnIn'> & {\n direction: EffectFourCorners;\n power?: EffectPower;\n};\nexport type CircleIn = BaseDataItemLike<'CircleIn'> & {\n direction: EffectTwoSides;\n};\nexport type WinkIn = BaseDataItemLike<'WinkIn'> & {\n direction: 'vertical' | 'horizontal';\n};\nexport type TiltIn = BaseDataItemLike<'TiltIn'> & {\n direction: EffectTwoSides;\n};\nexport type ShapeIn = BaseDataItemLike<'ShapeIn'> & {\n shape: 'circle' | 'ellipse' | 'rectangle' | 'diamond' | 'window';\n direction: EffectEightDirections | 'center';\n};\n\nexport type ShuttersIn = BaseDataItemLike<'ShuttersIn'> & {\n direction: EffectFourDirections;\n shutters: number;\n staggered: boolean;\n power?: EffectPower;\n};\nexport type GrowIn = BaseDataItemLike<'GrowIn'> & {\n direction: number;\n distance: UnitLengthPercentage;\n power?: EffectPower;\n initialScale?: number;\n};\nexport type RevealIn = BaseDataItemLike<'RevealIn'> & {\n direction: EffectFourDirections;\n};\nexport type BlurIn = BaseDataItemLike<'BlurIn'> & {\n blur?: number;\n power?: EffectPower;\n};\n\nexport type AnimationOptionsTypes = {\n time: TimeAnimationOptions & AnimationExtraOptions;\n scrub: ScrubAnimationOptions & AnimationExtraOptions;\n};\n\nexport type AnimationEffectAPI<Enum extends keyof AnimationOptionsTypes> = {\n web: (\n animationOptions: AnimationOptionsTypes[Enum],\n dom?: DomApi,\n options?: Record<string, any>,\n ) => AnimationData[];\n getNames: (animationOptions: AnimationOptionsTypes[Enum]) => string[];\n style?: (options: AnimationOptionsTypes[Enum]) => AnimationData[];\n prepare?: (options: AnimationOptionsTypes[Enum], dom?: DomApi) => void;\n};\n\nexport type WebAnimationEffectFactory<\n Enum extends keyof AnimationOptionsTypes,\n> = (\n animationOptions: AnimationOptionsTypes[Enum],\n dom?: DomApi,\n options?: Record<string, any>,\n) => AnimationData[];\n\nexport type EntranceAnimation =\n | FadeIn\n | ArcIn\n | CurveIn\n | DropIn\n | ExpandIn\n | FlipIn\n | FloatIn\n | FoldIn\n | SlideIn\n | SpinIn\n | BounceIn\n | PunchIn\n | GlideIn\n | GlitchIn\n | TurnIn\n | CircleIn\n | WinkIn\n | TiltIn\n | ShapeIn\n | ShuttersIn\n | GrowIn\n | RevealIn\n | BlurIn;\nexport type EntranceAnimations = Record<\n EntranceAnimation['type'],\n AnimationEffectAPI<'time'>\n>;\n\nexport type Breathe = BaseDataItemLike<'Breathe'> & {\n direction: 'vertical' | 'horizontal' | 'center';\n distance: UnitLengthPercentage;\n};\nexport type Pulse = BaseDataItemLike<'Pulse'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Spin = BaseDataItemLike<'Spin'> & {\n direction: 'clockwise' | 'counter-clockwise';\n power?: EffectPower;\n};\nexport type Poke = BaseDataItemLike<'Poke'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n intensity?: number;\n};\nexport type Flash = BaseDataItemLike<'Flash'>;\nexport type Swing = BaseDataItemLike<'Swing'> & {\n power?: EffectPower;\n swing?: number;\n direction?: EffectFourDirections;\n};\nexport type Flip = BaseDataItemLike<'Flip'> & {\n direction: 'vertical' | 'horizontal';\n power?: EffectPower;\n};\nexport type Rubber = BaseDataItemLike<'Rubber'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Fold = BaseDataItemLike<'Fold'> & {\n direction: EffectFourDirections;\n power?: EffectPower;\n angle?: number;\n};\nexport type Jello = BaseDataItemLike<'Jello'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Wiggle = BaseDataItemLike<'Wiggle'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Bounce = BaseDataItemLike<'Bounce'> & {\n power?: EffectPower;\n intensity?: number;\n};\nexport type Cross = BaseDataItemLike<'Cross'> & {\n direction: EffectEightDirections;\n};\nexport type DVD = BaseDataItemLike<'DVD'> & {\n power?: EffectPower;\n};\n\nexport type Blink = BaseDataItemLike<'Blink'> & {\n power?: EffectPower;\n scale?: number;\n distance?: UnitLengthPercentage;\n};\n\nexport type OngoingAnimation =\n | Breathe\n | Blink\n | Pulse\n | Spin\n | Poke\n | Flash\n | Swing\n | Flip\n | Rubber\n | Fold\n | Jello\n | Wiggle\n | Bounce\n | Cross\n | DVD;\nexport type OngoingAnimations = Record<\n OngoingAnimation['type'],\n AnimationEffectAPI<'time'>\n>;\n\nexport type ArcScroll = BaseDataItemLike<'ArcScroll'> & {\n direction: 'vertical' | 'horizontal';\n range?: EffectScrollRange;\n};\nexport type BlurScroll = BaseDataItemLike<'BlurScroll'> & {\n power?: EffectPower;\n range?: EffectScrollRange;\n blur?: number;\n};\nexport type FadeScroll = BaseDataItemLike<'FadeScroll'> & {\n range: EffectScrollRange;\n opacity: number;\n};\nexport type FlipScroll = BaseDataItemLike<'FlipScroll'> & {\n direction: 'vertical' | 'horizontal';\n power?: EffectPower;\n range?: EffectScrollRange;\n rotate?: number;\n};\nexport type GrowScroll = BaseDataItemLike<'GrowScroll'> & {\n direction: EffectNineDirections;\n power?: EffectPower;\n range?: EffectScrollRange;\n scale?: number;\n speed?: number;\n};\nexport type MoveScroll = BaseDataItemLike<'MoveScroll'> & {\n angle: number;\n power?: EffectPower;\n range?: EffectScrollRange;\n distance?: UnitLengthPercentage;\n};\nexport type PanScroll = BaseDataItemLike<'PanScroll'> & {\n direction: EffectTwoSides;\n distance: UnitLengthPercentage;\n startFromOffScreen: boolean;\n range?: EffectScrollRange;\n};\nexport type ParallaxScroll = BaseDataItemLike<'ParallaxScroll'> & {\n speed: number;\n range?: EffectScrollRange;\n};\nexport type RevealScroll = BaseDataItemLike<'RevealScroll'> & {\n direction: EffectFourDirections;\n range?: EffectScrollRange;\n};\nexport type ShapeScroll = BaseDataItemLike<'ShapeScroll'> & {\n shape: 'circle' | 'ellipse' | 'rectangle' | 'diamond' | 'window';\n range?: EffectScrollRange;\n power?: EffectPower;\n intensity?: number;\n};\nexport type ShrinkScroll = BaseDataItemLike<'ShrinkScroll'> & {\n direction: EffectNineDirections;\n power?: EffectPower;\n range?: EffectScrollRange;\n scale?: number;\n speed?: number;\n};\nexport type ShuttersScroll = BaseDataItemLike<'ShuttersScroll'> & {\n direction: EffectFourDirections;\n shutters: number;\n staggered: boolean;\n range?: EffectScrollRange;\n};\nexport type SkewPanScroll = BaseDataItemLike<'SkewPanScroll'> & {\n direction: EffectTwoSides;\n range?: EffectScrollRange;\n power?: EffectPower;\n skew?: number;\n};\nexport type SlideScroll = BaseDataItemLike<'SlideScroll'> & {\n direction: EffectFourDirections;\n range?: EffectScrollRange;\n};\nexport type Spin3dScroll = BaseDataItemLike<'Spin3dScroll'> & {\n range?: EffectScrollRange;\n power?: EffectPower;\n rotate?: number;\n speed?: number;\n};\nexport type SpinScroll = BaseDataItemLike<'SpinScroll'> & {\n direction: 'clockwise' | 'counter-clockwise';\n spins: number;\n range?: EffectScrollRange;\n power?: EffectPower;\n scale?: number;\n};\nexport type StretchScroll = BaseDataItemLike<'StretchScroll'> & {\n power?: EffectPower;\n range?: EffectScrollRange;\n stretch?: number;\n};\nexport type TiltScroll = BaseDataItemLike<'TiltScroll'> & {\n direction: EffectTwoSides;\n range?: EffectScrollRange;\n power?: EffectPower;\n distance?: number;\n};\nexport type TurnScroll = BaseDataItemLike<'TurnScroll'> & {\n direction: EffectTwoSides;\n spin: 'clockwise' | 'counter-clockwise';\n range?: EffectScrollRange;\n power?: EffectPower;\n scale?: number;\n};\n\nexport type ScrollAnimation =\n | ArcScroll\n | BlurScroll\n | FadeScroll\n | FlipScroll\n | GrowScroll\n | MoveScroll\n | PanScroll\n | ParallaxScroll\n | RevealScroll\n | ShapeScroll\n | ShuttersScroll\n | ShrinkScroll\n | SkewPanScroll\n | SlideScroll\n | Spin3dScroll\n | SpinScroll\n | StretchScroll\n | TiltScroll\n | TurnScroll;\nexport type ScrollAnimations = Record<\n ScrollAnimation['type'],\n WebAnimationEffectFactory<'scrub'>\n>;\n\nexport type BgCloseUp = BaseDataItemLike<'BgCloseUp'> & {\n scale?: number;\n};\nexport type BgFade = BaseDataItemLike<'BgFade'> & {\n range: 'in' | 'out';\n};\nexport type BgFadeBack = BaseDataItemLike<'BgFadeBack'> & {\n scale?: number;\n};\nexport type BgFake3D = BaseDataItemLike<'BgFake3D'> & {\n stretch?: number;\n zoom?: number;\n};\nexport type BgPan = BaseDataItemLike<'BgPan'> & {\n direction: 'left' | 'right';\n speed?: number;\n};\nexport type BgParallax = BaseDataItemLike<'BgParallax'> & {\n speed?: number;\n};\nexport type BgPullBack = BaseDataItemLike<'BgPullBack'> & {\n scale?: number;\n};\nexport type BgReveal = BaseDataItemLike<'BgReveal'>;\nexport type BgRotate = BaseDataItemLike<'BgRotate'> & {\n direction?: 'ccw' | 'cw';\n angle?: number;\n};\nexport type BgSkew = BaseDataItemLike<'BgSkew'> & {\n direction?: 'ccw' | 'cw';\n angle?: number;\n};\nexport type BgZoom = BaseDataItemLike<'BgZoom'> & {\n direction: 'in' | 'out';\n zoom?: number;\n};\nexport type ImageParallax = BaseDataItemLike<'ImageParallax'> & {\n reverse?: boolean;\n speed?: number;\n isPage?: boolean;\n};\n\nexport type BackgroundScrollAnimation =\n | BgCloseUp\n | BgFade\n | BgFadeBack\n | BgFake3D\n | BgPan\n | BgParallax\n | BgPullBack\n | BgReveal\n | BgRotate\n | BgSkew\n | BgZoom\n | ImageParallax;\n\nexport type BackgroundScrollAnimations = Record<\n BackgroundScrollAnimation['type'],\n WebAnimationEffectFactory<'scrub'>\n>;\n\ntype MouseEffectBase = {\n inverted?: boolean;\n};\n\ntype MouseEffectAxis = 'both' | 'horizontal' | 'vertical';\n\nexport type MousePivotAxis =\n | 'top'\n | 'bottom'\n | 'right'\n | 'left'\n | 'center-horizontal'\n | 'center-vertical';\n\nexport type AiryMouse = BaseDataItemLike<'AiryMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n angle?: number;\n power?: EffectPower;\n };\nexport type BlobMouse = BaseDataItemLike<'BlobMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n scale?: number;\n power?: EffectPower;\n };\nexport type BlurMouse = BaseDataItemLike<'BlurMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n scale?: number;\n blur?: number;\n perspective?: number;\n power?: EffectPower;\n };\nexport type BounceMouse = BaseDataItemLike<'BounceMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type ScaleMouse = BaseDataItemLike<'ScaleMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n scale?: number;\n power?: EffectPower;\n scaleDirection: EffectScaleDirection;\n };\nexport type SkewMouse = BaseDataItemLike<'SkewMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type SpinMouse = BaseDataItemLike<'SpinMouse'> &\n MouseEffectBase & {\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\nexport type SwivelMouse = BaseDataItemLike<'SwivelMouse'> &\n MouseEffectBase & {\n angle?: number;\n perspective?: number;\n pivotAxis?: MousePivotAxis;\n power?: EffectPower;\n };\nexport type Tilt3DMouse = BaseDataItemLike<'Tilt3DMouse'> &\n MouseEffectBase & {\n angle?: number;\n perspective?: number;\n power?: EffectPower;\n };\nexport type Track3DMouse = BaseDataItemLike<'Track3DMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n angle?: number;\n axis?: MouseEffectAxis;\n perspective?: number;\n power?: EffectPower;\n };\nexport type TrackMouse = BaseDataItemLike<'TrackMouse'> &\n MouseEffectBase & {\n distance?: UnitLengthPercentage;\n axis?: MouseEffectAxis;\n power?: EffectPower;\n };\n\nexport type CustomMouse = BaseDataItemLike<'CustomMouse'>;\n\nexport type Progress = {\n x: number;\n y: number;\n v?: { x: number; y: number };\n active?: boolean;\n};\nexport interface MouseAnimationInstance {\n target: HTMLElement;\n play: () => void;\n progress: (progress: Progress) => void;\n cancel: () => void;\n}\n\nexport interface CustomMouseAnimationInstance extends MouseAnimationInstance {\n getProgress: () => Progress;\n}\n\nexport type MouseAnimationFactory = (\n element: HTMLElement,\n) => MouseAnimationInstance;\n\nexport type MouseAnimationFactoryCreate = (\n options: ScrubAnimationOptions,\n dom?: DomApi,\n) => MouseAnimationFactory;\n\nexport type MouseAnimation =\n | AiryMouse\n | BlobMouse\n | BlurMouse\n | BounceMouse\n | CustomMouse\n | ScaleMouse\n | SkewMouse\n | SpinMouse\n | SwivelMouse\n | Tilt3DMouse\n | Track3DMouse\n | TrackMouse;\nexport type MouseAnimations = Record<\n MouseAnimation['type'],\n MouseAnimationFactoryCreate\n>;\n\nexport type NamedEffect =\n | EntranceAnimation\n | OngoingAnimation\n | ScrollAnimation\n | MouseAnimation\n | BackgroundScrollAnimation;\n\nexport type CustomEffect =\n | {\n ranges: { name: string; min: number; max: number; step?: number }[];\n }\n | ((element: Element | null, progress: number | null) => void);\n\nexport type AnimationExtraOptions = {\n effectId?: string;\n effect?: (\n progress: () => number | { x: number | undefined; y: number | undefined },\n ) => void;\n};\n\nexport type AnimationOptions = (TimeAnimationOptions | ScrubAnimationOptions) &\n AnimationExtraOptions;\n\nexport type MotionAnimationOptions<T extends keyof AnimationOptionsTypes> =\n AnimationOptionsTypes[T];\n\nexport type MeasureCallback = (\n fn: (target: HTMLElement | null) => void,\n) => void;\nexport type DomApi = { measure: MeasureCallback; mutate: MeasureCallback };\n\nexport type NamedEffectFunction = (\n options: AnimationOptions,\n domApi?: DomApi | undefined,\n config?: Record<string, any>,\n) => AnimationData[];\n\nexport type ScrubTransitionEasing =\n | 'linear'\n | 'hardBackOut'\n | 'easeOut'\n | 'elastic'\n | 'bounce';\n\nexport type RangeOffset = {\n name?:\n | 'entry'\n | 'exit'\n | 'contain'\n | 'cover'\n | 'entry-crossing'\n | 'exit-crossing';\n offset?: LengthPercentage;\n};\n\nexport type MotionKeyframeEffect = BaseDataItemLike<'KeyframeEffect'> & {\n name: string;\n keyframes: Keyframe[];\n};\n\nexport type TimeAnimationOptions = {\n id?: string;\n keyframeEffect?: MotionKeyframeEffect;\n namedEffect?: NamedEffect;\n customEffect?: CustomEffect;\n duration?: number;\n delay?: number;\n endDelay?: number;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: AnimationFillMode;\n reversed?: boolean;\n};\n\ntype ScrubAnimationDataBase = {\n id?: string;\n keyframeEffect?: MotionKeyframeEffect;\n namedEffect?: NamedEffect;\n customEffect?: CustomEffect;\n startOffset?: RangeOffset;\n endOffset?: RangeOffset;\n playbackRate?: number;\n easing?: string;\n iterations?: number;\n fill?: AnimationFillMode;\n alternate?: boolean;\n reversed?: boolean;\n transitionDuration?: number;\n transitionDelay?: number;\n transitionEasing?: ScrubTransitionEasing;\n centeredToTarget?: boolean;\n};\n\nexport type ScrubAnimationOptions = ScrubAnimationDataBase & {\n duration?: LengthPercentage;\n};\n\ntype AnimationDataExtra = {\n name?: string; // TODO: need to be added to all animations and then be made required\n keyframes: Record<string, string | number | undefined>[];\n custom?: Record<string, string | number | undefined>;\n composite?: CompositeOperation;\n part?: string;\n timing?: Partial<EffectTiming>;\n};\n\nexport type AnimationDataForScrub = ScrubAnimationDataBase & {\n duration?: LengthPercentage | number;\n startOffsetAdd?: string;\n endOffsetAdd?: string;\n};\n\nexport type AnimationData = (TimeAnimationOptions | AnimationDataForScrub) &\n AnimationDataExtra;\n\n// TODO: need it?\nexport type AnimationProperties = {\n groups?: string[];\n schema: { [key: string]: any };\n};\n\nexport type TriggerVariant = {\n id: string;\n trigger: 'view-progress' | 'pointer-move';\n componentId: string;\n};\n\nexport type AnimationGroupOptions = AnimationOptions & {\n trigger?: Partial<TriggerVariant> | undefined;\n startOffsetAdd?: string | undefined;\n endOffsetAdd?: string | undefined;\n measured?: Promise<void>;\n};\n\nexport type Shape = 'ellipse' | 'circle' | 'rectangle' | 'diamond' | 'window';\n\nexport interface ScrubScrollScene {\n start: RangeOffset;\n end: RangeOffset;\n viewSource: HTMLElement;\n ready: Promise<void>;\n getProgress(): number;\n effect(__: any, p: number): void;\n disabled: boolean;\n destroy(): void;\n groupId?: string;\n}\n\nexport interface ScrubPointerScene {\n target?: HTMLElement;\n centeredToTarget?: boolean;\n transitionDuration?: number;\n transitionEasing?: ScrubTransitionEasing;\n getProgress(): Progress;\n effect(p: Progress): void;\n disabled: boolean;\n destroy(): void;\n allowActiveEvent?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -89,7 +89,7 @@ function getNamedEffect(animation) {
89
89
  }
90
90
  return null;
91
91
  }
92
- function getEffectsData(animations, effectId) {
92
+ function getEffectsData(animations, trigger, effectId) {
93
93
  // process each AnimationData object into a KeyframeEffect object
94
94
  return animations.map((effect, index) => {
95
95
  // prepare the KeyframeEffectOptions object
@@ -101,8 +101,8 @@ function getEffectsData(animations, effectId) {
101
101
  direction: getDirection(effect)
102
102
  };
103
103
 
104
- // if this is a TimeAnimation then set the duration and delay as time values
105
- if (effect.type.startsWith('Time')) {
104
+ // if this is a time-based animation then set the duration and delay as time values
105
+ if (isNotAScrubTrigger(trigger)) {
106
106
  effectOptions.duration = effect.duration;
107
107
  effectOptions.delay = effect.delay || 0;
108
108
  } else {
@@ -125,5 +125,8 @@ function getEffectsData(animations, effectId) {
125
125
  };
126
126
  });
127
127
  }
128
- export { getElement, getElementMotionPart, getNamedEffect, getEffectsData, measure, mutate, getDirection, getLength, getRanges };
128
+ function isNotAScrubTrigger(trigger) {
129
+ return !trigger || trigger.trigger !== 'pointer-move' && trigger.trigger !== 'view-progress';
130
+ }
131
+ export { isNotAScrubTrigger, getElement, getElementMotionPart, getNamedEffect, getEffectsData, measure, mutate, getDirection, getLength, getRanges };
129
132
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["scrollAnimations","entranceAnimations","ongoingAnimations","mouseAnimations","backgroundScrollAnimations","getCssUnits","getEasing","fastdom","getElement","id","ownerDocument","document","getElementById","getElementMotionPart","element","part","matches","querySelector","getDirection","effect","alternate","reversed","getLength","length","value","type","getRange","range","add","isEnd","name","offset","getRanges","start","startOffset","startOffsetAdd","end","endOffset","endOffsetAdd","measure","target","fn","mutate","getNamedEffect","animation","namedEffect","keyframeEffect","animation_","keyframes","getNames","effectId","uid","web","style","customEffect","getEffectsData","animations","map","index","effectOptions","fill","easing","iterations","Infinity","composite","direction","startsWith","duration","delay","window","ViewTimeline","options"],"sources":["../../../src/api/common.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationOptions,\n BackgroundScrollAnimations,\n EntranceAnimations,\n MeasureCallback,\n MouseAnimations,\n OngoingAnimations,\n RangeOffset,\n ScrollAnimations,\n TimeAnimationOptions,\n UnitLengthPercentage,\n} from '../types';\nimport { scrollAnimations } from '../library/scroll';\nimport { entranceAnimations } from '../library/entrance';\nimport { ongoingAnimations } from '../library/ongoing';\nimport { mouseAnimations } from '../library/mouse';\nimport { backgroundScrollAnimations } from '../library/backgroundScroll';\nimport { getCssUnits, getEasing } from '../utils';\nimport fastdom from 'fastdom';\n\nfunction getElement(\n id: string | null,\n ownerDocument?: Document,\n): HTMLElement | null {\n return id ? (ownerDocument || document).getElementById(id) : null;\n}\n\nfunction getElementMotionPart(element: Element | null, part: string) {\n if (element?.matches(`[data-motion-part~=\"${part}\"]`)) {\n return element;\n }\n return element?.querySelector(`[data-motion-part~=\"${part}\"]`);\n}\n\nfunction getDirection(\n effect: AnimationData,\n): KeyframeEffectOptions['direction'] {\n const alternate = effect.alternate ? 'alternate' : '';\n return effect.reversed\n ? (`${alternate ? `${alternate}-` : ''}reverse` as\n | 'reverse'\n | 'alternate-reverse')\n : alternate || 'normal';\n}\n\nfunction getLength(length: UnitLengthPercentage): string {\n return `${length.value}${getCssUnits(length.type)}`;\n}\n\nfunction getRange(\n range: RangeOffset,\n add: string | undefined,\n isEnd?: boolean,\n) {\n // according to the CSS spec if the end range is a <length> then it is calculated from the start of the named range\n // our model assumes that <length> in end range is calculated from the end of the named range\n return `${range.name || 'cover'} ${\n isEnd && range.offset!.type !== 'percentage'\n ? `calc(100% + ${getLength(range.offset!)}${add ? ` + ${add}` : ''})`\n : add\n ? `calc(${getLength(range.offset!)} + ${add})`\n : getLength(range.offset!)\n }`;\n}\n\nfunction getRanges(effect: AnimationDataForScrub) {\n return {\n start: getRange(effect.startOffset!, effect.startOffsetAdd),\n end: getRange(effect.endOffset!, effect.endOffsetAdd, true),\n };\n}\n\nfunction measure(target: HTMLElement | null): MeasureCallback {\n return (fn) => fastdom.measure(() => fn(target));\n}\n\nfunction mutate(target: HTMLElement | null): MeasureCallback {\n return (fn) => fastdom.mutate(() => fn(target));\n}\n\nfunction getNamedEffect(animation: AnimationOptions) {\n if (animation.namedEffect) {\n const name = animation.namedEffect.type;\n\n // check each preset library for the named effect\n if (name in scrollAnimations) {\n return scrollAnimations[name as keyof ScrollAnimations];\n } else if (name in entranceAnimations) {\n return entranceAnimations[name as keyof EntranceAnimations];\n } else if (name in ongoingAnimations) {\n return ongoingAnimations[name as keyof OngoingAnimations];\n } else if (name in mouseAnimations) {\n return mouseAnimations[name as keyof MouseAnimations];\n } else if (name in backgroundScrollAnimations) {\n return backgroundScrollAnimations[\n name as keyof BackgroundScrollAnimations\n ];\n }\n } else if (animation.keyframeEffect) {\n const effect = (animation_: AnimationOptions) => {\n const { name, keyframes } = animation_.keyframeEffect!;\n\n return [{ ...animation_, name, keyframes }];\n };\n const getNames = (animation_: AnimationOptions) => {\n const { effectId } = animation_;\n const { name } = animation_.keyframeEffect!;\n const uid = name || effectId;\n\n return uid ? [uid] : [];\n };\n return { web: effect, style: effect, getNames };\n } else if (animation.customEffect) {\n return (animation_: AnimationOptions) => [{ ...animation_, keyframes: [] }];\n }\n return null;\n}\n\nfunction getEffectsData(animations: AnimationData[], effectId?: string) {\n // process each AnimationData object into a KeyframeEffect object\n return animations.map((effect, index) => {\n // prepare the KeyframeEffectOptions object\n const effectOptions = {\n fill: effect.fill,\n easing: getEasing(effect.easing),\n iterations: effect.iterations === 0 ? Infinity : effect.iterations || 1,\n composite: effect.composite,\n direction: getDirection(effect),\n } as KeyframeEffectOptions & { rangeStart: string; rangeEnd: string };\n\n // if this is a TimeAnimation then set the duration and delay as time values\n if (effect.type.startsWith('Time')) {\n effectOptions.duration = effect.duration as number;\n effectOptions.delay = (effect as TimeAnimationOptions).delay || 0;\n } else {\n // if ViewTimeline is supported\n if (window.ViewTimeline) {\n // set duration to 'auto'\n effectOptions.duration = 'auto';\n } else {\n // if ViewTimeline not supported then put a 100ms value in duration get a progress we can easily relate to\n // we split the duration to 99.99ms and delay of 0.01ms to get the fill-mode effect working\n effectOptions.duration = 99.99;\n effectOptions.delay = 0.01;\n }\n }\n\n return {\n effect,\n options: effectOptions,\n id: effectId && `${effectId}-${index + 1}`,\n part: effect.part,\n };\n });\n}\n\nexport {\n getElement,\n getElementMotionPart,\n getNamedEffect,\n getEffectsData,\n measure,\n mutate,\n getDirection,\n getLength,\n getRanges,\n};\n"],"mappings":"AAcA,SAASA,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,eAAe,QAAQ,kBAAkB;AAClD,SAASC,0BAA0B,QAAQ,6BAA6B;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,UAAU;AACjD,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,UAAUA,CACjBC,EAAiB,EACjBC,aAAwB,EACJ;EACpB,OAAOD,EAAE,GAAG,CAACC,aAAa,IAAIC,QAAQ,EAAEC,cAAc,CAACH,EAAE,CAAC,GAAG,IAAI;AACnE;AAEA,SAASI,oBAAoBA,CAACC,OAAuB,EAAEC,IAAY,EAAE;EACnE,IAAID,OAAO,YAAPA,OAAO,CAAEE,OAAO,CAAC,uBAAuBD,IAAI,IAAI,CAAC,EAAE;IACrD,OAAOD,OAAO;EAChB;EACA,OAAOA,OAAO,oBAAPA,OAAO,CAAEG,aAAa,CAAC,uBAAuB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C,QAAQ,IAAI,GAAGA,QAAQ,IAAIQ,KAAK,GAAG,CAAC,EAAE;MAC1C3C,IAAI,EAAEI,MAAM,CAACJ;IACf,CAAC;EACH,CAAC,CAAC;AACJ;AAEA,SACEP,UAAU,EACVK,oBAAoB,EACpB8B,cAAc,EACdY,cAAc,EACdhB,OAAO,EACPG,MAAM,EACNxB,YAAY,EACZI,SAAS,EACTU,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["scrollAnimations","entranceAnimations","ongoingAnimations","mouseAnimations","backgroundScrollAnimations","getCssUnits","getEasing","fastdom","getElement","id","ownerDocument","document","getElementById","getElementMotionPart","element","part","matches","querySelector","getDirection","effect","alternate","reversed","getLength","length","value","type","getRange","range","add","isEnd","name","offset","getRanges","start","startOffset","startOffsetAdd","end","endOffset","endOffsetAdd","measure","target","fn","mutate","getNamedEffect","animation","namedEffect","keyframeEffect","animation_","keyframes","getNames","effectId","uid","web","style","customEffect","getEffectsData","animations","trigger","map","index","effectOptions","fill","easing","iterations","Infinity","composite","direction","isNotAScrubTrigger","duration","delay","window","ViewTimeline","options"],"sources":["../../../src/api/common.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationOptions,\n BackgroundScrollAnimations,\n EntranceAnimations,\n MeasureCallback,\n MouseAnimations,\n OngoingAnimations,\n RangeOffset,\n ScrollAnimations,\n TimeAnimationOptions,\n TriggerVariant,\n UnitLengthPercentage,\n} from '../types';\nimport { scrollAnimations } from '../library/scroll';\nimport { entranceAnimations } from '../library/entrance';\nimport { ongoingAnimations } from '../library/ongoing';\nimport { mouseAnimations } from '../library/mouse';\nimport { backgroundScrollAnimations } from '../library/backgroundScroll';\nimport { getCssUnits, getEasing } from '../utils';\nimport fastdom from 'fastdom';\n\nfunction getElement(\n id: string | null,\n ownerDocument?: Document,\n): HTMLElement | null {\n return id ? (ownerDocument || document).getElementById(id) : null;\n}\n\nfunction getElementMotionPart(element: Element | null, part: string) {\n if (element?.matches(`[data-motion-part~=\"${part}\"]`)) {\n return element;\n }\n return element?.querySelector(`[data-motion-part~=\"${part}\"]`);\n}\n\nfunction getDirection(\n effect: AnimationData,\n): KeyframeEffectOptions['direction'] {\n const alternate = effect.alternate ? 'alternate' : '';\n return effect.reversed\n ? (`${alternate ? `${alternate}-` : ''}reverse` as\n | 'reverse'\n | 'alternate-reverse')\n : alternate || 'normal';\n}\n\nfunction getLength(length: UnitLengthPercentage): string {\n return `${length.value}${getCssUnits(length.type)}`;\n}\n\nfunction getRange(\n range: RangeOffset,\n add: string | undefined,\n isEnd?: boolean,\n) {\n // according to the CSS spec if the end range is a <length> then it is calculated from the start of the named range\n // our model assumes that <length> in end range is calculated from the end of the named range\n return `${range.name || 'cover'} ${\n isEnd && range.offset!.type !== 'percentage'\n ? `calc(100% + ${getLength(range.offset!)}${add ? ` + ${add}` : ''})`\n : add\n ? `calc(${getLength(range.offset!)} + ${add})`\n : getLength(range.offset!)\n }`;\n}\n\nfunction getRanges(effect: AnimationDataForScrub) {\n return {\n start: getRange(effect.startOffset!, effect.startOffsetAdd),\n end: getRange(effect.endOffset!, effect.endOffsetAdd, true),\n };\n}\n\nfunction measure(target: HTMLElement | null): MeasureCallback {\n return (fn) => fastdom.measure(() => fn(target));\n}\n\nfunction mutate(target: HTMLElement | null): MeasureCallback {\n return (fn) => fastdom.mutate(() => fn(target));\n}\n\nfunction getNamedEffect(animation: AnimationOptions) {\n if (animation.namedEffect) {\n const name = animation.namedEffect.type;\n\n // check each preset library for the named effect\n if (name in scrollAnimations) {\n return scrollAnimations[name as keyof ScrollAnimations];\n } else if (name in entranceAnimations) {\n return entranceAnimations[name as keyof EntranceAnimations];\n } else if (name in ongoingAnimations) {\n return ongoingAnimations[name as keyof OngoingAnimations];\n } else if (name in mouseAnimations) {\n return mouseAnimations[name as keyof MouseAnimations];\n } else if (name in backgroundScrollAnimations) {\n return backgroundScrollAnimations[\n name as keyof BackgroundScrollAnimations\n ];\n }\n } else if (animation.keyframeEffect) {\n const effect = (animation_: AnimationOptions) => {\n const { name, keyframes } = animation_.keyframeEffect!;\n\n return [{ ...animation_, name, keyframes }];\n };\n const getNames = (animation_: AnimationOptions) => {\n const { effectId } = animation_;\n const { name } = animation_.keyframeEffect!;\n const uid = name || effectId;\n\n return uid ? [uid] : [];\n };\n return { web: effect, style: effect, getNames };\n } else if (animation.customEffect) {\n return (animation_: AnimationOptions) => [{ ...animation_, keyframes: [] }];\n }\n return null;\n}\n\nfunction getEffectsData(\n animations: AnimationData[],\n trigger?: Partial<TriggerVariant>,\n effectId?: string,\n) {\n // process each AnimationData object into a KeyframeEffect object\n return animations.map((effect, index) => {\n // prepare the KeyframeEffectOptions object\n const effectOptions = {\n fill: effect.fill,\n easing: getEasing(effect.easing),\n iterations: effect.iterations === 0 ? Infinity : effect.iterations || 1,\n composite: effect.composite,\n direction: getDirection(effect),\n } as KeyframeEffectOptions & { rangeStart: string; rangeEnd: string };\n\n // if this is a time-based animation then set the duration and delay as time values\n if (isNotAScrubTrigger(trigger)) {\n effectOptions.duration = effect.duration as number;\n effectOptions.delay = (effect as TimeAnimationOptions).delay || 0;\n } else {\n // if ViewTimeline is supported\n if (window.ViewTimeline) {\n // set duration to 'auto'\n effectOptions.duration = 'auto';\n } else {\n // if ViewTimeline not supported then put a 100ms value in duration get a progress we can easily relate to\n // we split the duration to 99.99ms and delay of 0.01ms to get the fill-mode effect working\n effectOptions.duration = 99.99;\n effectOptions.delay = 0.01;\n }\n }\n\n return {\n effect,\n options: effectOptions,\n id: effectId && `${effectId}-${index + 1}`,\n part: effect.part,\n };\n });\n}\n\nfunction isNotAScrubTrigger(trigger?: Partial<TriggerVariant>) {\n return (\n !trigger ||\n (trigger.trigger !== 'pointer-move' && trigger.trigger !== 'view-progress')\n );\n}\n\nexport {\n isNotAScrubTrigger,\n getElement,\n getElementMotionPart,\n getNamedEffect,\n getEffectsData,\n measure,\n mutate,\n getDirection,\n getLength,\n getRanges,\n};\n"],"mappings":"AAeA,SAASA,gBAAgB,QAAQ,m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AAM,CAAC4C,UAAU,IAAI,CAAC;MACvEE,SAAS,EAAE9C,MAAM,CAAC8C,SAAS;MAC3BC,SAAS,EAAEhD,YAAY,CAACC,MAAM;IAChC,CAAqE;;IAErE;IACA,IAAIgD,kBAAkB,CAACV,OAAO,CAAC,EAAE;MAC/BG,aAAa,CAACQ,QAAQ,GAAGjD,MAAM,CAACiD,QAAkB;MAClDR,aAAa,CAACS,KAAK,GAAIlD,MAAM,CAA0BkD,KAAK,IAAI,CAAC;IACnE,CAAC,MAAM;MACL;MACA,IAAIC,MAAM,CAACC,YAAY,EAAE;QACvB;QACAX,aAAa,CAACQ,QAAQ,GAAG,MAAM;MACjC,CAAC,MAAM;QACL;QACA;QACAR,aAAa,CAACQ,QAAQ,GAAG,KAAK;QAC9BR,aAAa,CAACS,KAAK,GAAG,IAAI;MAC5B;IACF;IAEA,OAAO;MACLlD,MAAM;MACNqD,OAAO,EAAEZ,aAAa;MACtBnD,EAAE,EAAEyC,QAAQ,IAAI,GAAGA,QAAQ,IAAIS,KAAK,GAAG,CAAC,EAAE;MAC1C5C,IAAI,EAAEI,MAAM,CAACJ;IACf,CAAC;EACH,CAAC,CAAC;AACJ;AAEA,SAASoD,kBAAkBA,CAACV,OAAiC,EAAE;EAC7D,OACE,CAACA,OAAO,IACPA,OAAO,CAACA,OAAO,KAAK,cAAc,IAAIA,OAAO,CAACA,OAAO,KAAK,eAAgB;AAE/E;AAEA,SACEU,kBAAkB,EAClB3D,UAAU,EACVK,oBAAoB,EACpB8B,cAAc,EACdY,cAAc,EACdhB,OAAO,EACPG,MAAM,EACNxB,YAAY,EACZI,SAAS,EACTU,SAAS","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { getEffectsData, getRanges, getNamedEffect } from './common';
1
+ import { getEffectsData, getRanges, getNamedEffect, isNotAScrubTrigger } from './common';
2
2
  function getAnimationTarget(target, part) {
3
3
  return target ? `#${target}${part ? `[data-motion-part~="${part}"]` : ''}` : '';
4
4
  }
@@ -15,10 +15,10 @@ function getAnimationAsCSS(data, isRunning) {
15
15
  const isAutoDuration = duration === 'auto';
16
16
  return `${animationName} ${isAutoDuration ? 'auto' : `${duration}ms`}${isAutoDuration ? ' ' : ` ${delay || 1}ms `}${easing}${fill && fill !== 'none' ? ` ${fill}` : ''} ${!iterations || iterations === Infinity ? 'infinite' : iterations}${direction === 'normal' ? '' : ` ${direction}`} ${isRunning ? '' : 'paused'}`;
17
17
  }
18
- function getCSSAnimationEffect(preset, animation) {
18
+ function getCSSAnimationEffect(preset, animation, trigger) {
19
19
  if (preset != null && preset.style) {
20
20
  // validate duration is a number over 0
21
- if (animation.type === 'TimeAnimationOptions') {
21
+ if (isNotAScrubTrigger(trigger)) {
22
22
  animation.duration = animation.duration || 1;
23
23
  }
24
24
  return preset.style(animation);
@@ -29,7 +29,7 @@ function getCSSAnimation(target, animationOptions, trigger) {
29
29
  // get the preset for the given animation options
30
30
  const namedEffect = getNamedEffect(animationOptions);
31
31
  const animationsData = getCSSAnimationEffect(namedEffect, animationOptions);
32
- const data = getEffectsData(animationsData, animationOptions.effectId);
32
+ const data = getEffectsData(animationsData, trigger, animationOptions.effectId);
33
33
  const isViewProgress = (trigger == null ? void 0 : trigger.trigger) === 'view-progress';
34
34
  return data.map((item, index) => {
35
35
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["getEffectsData","getRanges","getNamedEffect","getAnimationTarget","target","part","getAnimationAsCSS","data","isRunning","duration","delay","iterations","fill","easing","direction","options","animationName","effect","name","isAutoDuration","Infinity","getCSSAnimationEffect","preset","animation","style","type","getCSSAnimation","animationOptions","trigger","namedEffect","animationsData","effectId","isViewProgress","map","item","index","start","end","composition","composite","custom","keyframes","id","animationTimeline","animationRange"],"sources":["../../../src/api/cssAnimations.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationEffectAPI,\n AnimationOptions,\n TriggerVariant,\n} from '../types';\nimport { getEffectsData, getRanges, getNamedEffect } from './common';\n\nfunction getAnimationTarget(target: string | null, part: string | undefined) {\n return target\n ? `#${target}${part ? `[data-motion-part~=\"${part}\"]` : ''}`\n : '';\n}\n\nfunction getAnimationAsCSS(\n data: {\n effect: AnimationData;\n options: KeyframeEffectOptions;\n id: string | undefined;\n part: string | undefined;\n },\n isRunning?: boolean,\n) {\n const {\n duration,\n delay,\n iterations = 1,\n fill,\n easing = 'linear',\n direction,\n } = data.options;\n const animationName = data.effect.name;\n const isAutoDuration = duration === 'auto';\n\n return `${animationName} ${isAutoDuration ? 'auto' : `${duration}ms`}${\n isAutoDuration ? ' ' : ` ${delay || 1}ms `\n }${easing}${fill && fill !== 'none' ? ` ${fill}` : ''} ${\n !iterations || iterations === Infinity ? 'infinite' : iterations\n }${direction === 'normal' ? '' : ` ${direction}`} ${\n isRunning ? '' : 'paused'\n }`;\n}\n\nfunction getCSSAnimationEffect(\n preset: AnimationEffectAPI<any> | null,\n animation: AnimationOptions,\n): AnimationData[] {\n if (preset?.style) {\n // validate duration is a number over 0\n if (animation.type === 'TimeAnimationOptions') {\n animation.duration = animation.duration || 1;\n }\n\n return preset.style(animation);\n }\n\n return [];\n}\n\nfunction getCSSAnimation(\n target: string | null,\n animationOptions: AnimationOptions,\n trigger?: TriggerVariant,\n) {\n // get the preset for the given animation options\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n const animationsData = getCSSAnimationEffect(namedEffect, animationOptions);\n const data = getEffectsData(animationsData, animationOptions.effectId);\n const isViewProgress = trigger?.trigger === 'view-progress';\n\n return data.map((item, index) => {\n const { start, end }: { start?: string; end?: string } = isViewProgress\n ? getRanges(item.effect as AnimationDataForScrub)\n : {};\n\n return {\n target: getAnimationTarget(target, item.part),\n animation: getAnimationAsCSS(item, isViewProgress),\n composition: item.options.composite,\n custom: item.effect.custom,\n name: item.effect.name,\n keyframes: item.effect.keyframes,\n id: item.id && `${item.id}-${index + 1}`,\n animationTimeline: isViewProgress ? `--${trigger?.id}` : '',\n animationRange: start || end ? `${start} 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EAAE;MAC3DE,cAAc,EAAER,KAAK,IAAIC,GAAG,GAAG,GAAGD,KAAK,IAAIC,GAAG,EAAE,GAAG;IACrD,CAAC;EACH,CAAC,CAAC;AACJ;AAEA,SAASX,eAAe,EAAEL,qBAAqB,EAAEf,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["getEffectsData","getRanges","getNamedEffect","isNotAScrubTrigger","getAnimationTarget","target","part","getAnimationAsCSS","data","isRunning","duration","delay","iterations","fill","easing","direction","options","animationName","effect","name","isAutoDuration","Infinity","getCSSAnimationEffect","preset","animation","trigger","style","getCSSAnimation","animationOptions","namedEffect","animationsData","effectId","isViewProgress","map","item","index","start","end","composition","composite","custom","keyframes","id","animationTimeline","animationRange"],"sources":["../../../src/api/cssAnimations.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationEffectAPI,\n AnimationOptions,\n TriggerVariant,\n} from '../types';\nimport {\n getEffectsData,\n getRanges,\n getNamedEffect,\n isNotAScrubTrigger,\n} from './common';\n\nfunction getAnimationTarget(target: string | null, part: string | undefined) {\n return target\n ? `#${target}${part ? `[data-motion-part~=\"${part}\"]` : ''}`\n : '';\n}\n\nfunction getAnimationAsCSS(\n data: {\n effect: AnimationData;\n options: KeyframeEffectOptions;\n id: string | undefined;\n part: string | undefined;\n },\n isRunning?: boolean,\n) {\n const {\n duration,\n delay,\n iterations = 1,\n fill,\n easing = 'linear',\n direction,\n } = data.options;\n const animationName = data.effect.name;\n const isAutoDuration = duration === 'auto';\n\n return `${animationName} ${isAutoDuration ? 'auto' : `${duration}ms`}${\n isAutoDuration ? ' ' : ` ${delay || 1}ms `\n }${easing}${fill && fill !== 'none' ? ` ${fill}` : ''} ${\n !iterations || iterations === Infinity ? 'infinite' : iterations\n }${direction === 'normal' ? '' : ` ${direction}`} ${\n isRunning ? '' : 'paused'\n }`;\n}\n\nfunction getCSSAnimationEffect(\n preset: AnimationEffectAPI<any> | null,\n animation: AnimationOptions,\n trigger?: Partial<TriggerVariant>,\n): AnimationData[] {\n if (preset?.style) {\n // validate duration is a number over 0\n if (isNotAScrubTrigger(trigger)) {\n animation.duration = animation.duration || 1;\n }\n\n return preset.style(animation);\n }\n\n return [];\n}\n\nfunction getCSSAnimation(\n target: string | null,\n animationOptions: AnimationOptions,\n trigger?: TriggerVariant,\n) {\n // get the preset for the given animation options\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n const animationsData = getCSSAnimationEffect(namedEffect, animationOptions);\n const data = getEffectsData(\n animationsData,\n trigger,\n animationOptions.effectId,\n );\n const isViewProgress = trigger?.trigger === 'view-progress';\n\n return data.map((item, index) => {\n const { start, end }: { start?: string; end?: string } = isViewProgress\n ? getRanges(item.effect as AnimationDataForScrub)\n : {};\n\n return {\n target: getAnimationTarget(target, item.part),\n animation: getAnimationAsCSS(item, isViewProgress),\n composition: item.options.composite,\n custom: item.effect.custom,\n name: item.effect.name,\n keyframes: item.effect.keyframes,\n id: item.id && `${item.id}-${index + 1}`,\n animationTimeline: isViewProgress ? `--${trigger?.id}` : '',\n animationRange: start || end ? `${start} ${end}` : '',\n };\n });\n}\n\nexport { getCSSAnimation, getCSSAnimationEffect, getAnimationAsCSS };\n"],"mappings":"AAOA,SACEA,cAAc,EACdC,SAAS,EACTC,cAAc,EACdC,kBAAkB,QACb,UAAU;AAEjB,SAASC,kBAAkBA,CAACC,MAAqB,EAAEC,IAAwB,EAAE;EAC3E,OAAOD,MAAM,GACT,IAAIA,MAAM,GAAGC,IAAI,GAAG,uBAAuBA,IAAI,IAAI,GAAG,EAAE,EAAE,GAC1D,EAAE;AACR;AAEA,SAASC,iBAAiBA,CACxBC,IAKC,EACDC,SAAmB,EACnB;EACA,MAAM;IACJC,QAAQ;IACRC,KAAK;IACLC,UAAU,GAAG,CAAC;IACdC,IAAI;IACJC,MAAM,GAAG,QAAQ;IACjBC;EACF,CAAC,GAAGP,IAAI,CAACQ,OAAO;EAChB,MAAMC,aAAa,GAAGT,I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AACC,IAAI,EAAEC,KAAK,KAAK;IAC/B,MAAM;MAAEC,KAAK;MAAEC;IAAsC,CAAC,GAAGL,cAAc,GACnE/B,SAAS,CAACiC,IAAI,CAAChB,MAA+B,CAAC,GAC/C,CAAC,CAAC;IAEN,OAAO;MACLb,MAAM,EAAED,kBAAkB,CAACC,MAAM,EAAE6B,IAAI,CAAC5B,IAAI,CAAC;MAC7CkB,SAAS,EAAEjB,iBAAiB,CAAC2B,IAAI,EAAEF,cAAc,CAAC;MAClDM,WAAW,EAAEJ,IAAI,CAAClB,OAAO,CAACuB,SAAS;MACnCC,MAAM,EAAEN,IAAI,CAAChB,MAAM,CAACsB,MAAM;MAC1BrB,IAAI,EAAEe,IAAI,CAAChB,MAAM,CAACC,IAAI;MACtBsB,SAAS,EAAEP,IAAI,CAAChB,MAAM,CAACuB,SAAS;MAChCC,EAAE,EAAER,IAAI,CAACQ,EAAE,IAAI,GAAGR,IAAI,CAACQ,EAAE,IAAIP,KAAK,GAAG,CAAC,EAAE;MACxCQ,iBAAiB,EAAEX,cAAc,GAAG,KAAKP,OAAO,oBAAPA,OAAO,CAAEiB,EAAE,EAAE,GAAG,EAAE;MAC3DE,cAAc,EAAER,KAAK,IAAIC,GAAG,GAAG,GAAGD,KAAK,IAAIC,GAAG,EAAE,GAAG;IACrD,CAAC;EACH,CAAC,CAAC;AACJ;AAEA,SAASV,eAAe,EAAEL,qBAAqB,EAAEf,iBAAiB","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  import { CustomAnimation } from '../CustomAnimation';
2
2
  import { AnimationGroup } from '../AnimationGroup';
3
- import { getElement, getElementMotionPart, measure, mutate, getRanges, getNamedEffect, getEffectsData } from './common';
3
+ import { getElement, getElementMotionPart, measure, mutate, getRanges, getNamedEffect, getEffectsData, isNotAScrubTrigger } from './common';
4
4
  import fastdom from 'fastdom';
5
- function getWebAnimationEffect(preset, animation, target, options) {
5
+ function getWebAnimationEffect(preset, animation, target, trigger, options) {
6
6
  if (preset) {
7
7
  // validate duration is a number over 0
8
- if (animation.type === 'TimeAnimationOptions') {
8
+ if (isNotAScrubTrigger(trigger)) {
9
9
  animation.duration = animation.duration || 1;
10
10
  if (options != null && options.reducedMotion) {
11
11
  if (animation.iterations === 1 || animation.iterations == undefined) {
@@ -45,14 +45,14 @@ function getWebAnimation(target, animationOptions, trigger, options, ownerDocume
45
45
 
46
46
  // TODO: need to fix the type here, currently lying about the returned type to be WebAnimationEffectFactory instead of MouseAnimationFactoryCreate
47
47
  const mouseAnimationPreset = getNamedEffect(effectOptions);
48
- const mouseAnimationFactory = getWebAnimationEffect(mouseAnimationPreset, animationOptions, element, options);
48
+ const mouseAnimationFactory = getWebAnimationEffect(mouseAnimationPreset, animationOptions, element, trigger, options);
49
49
  return mouseAnimationFactory(element);
50
50
  }
51
51
 
52
52
  // get the preset for the given animation options
53
53
  const namedEffect = getNamedEffect(animationOptions);
54
- const animationsData = getWebAnimationEffect(namedEffect, animationOptions, element, options);
55
- const data = getEffectsData(animationsData, animationOptions.effectId);
54
+ const animationsData = getWebAnimationEffect(namedEffect, animationOptions, element, trigger, options);
55
+ const data = getEffectsData(animationsData, trigger, animationOptions.effectId);
56
56
  let timeline;
57
57
  const isViewProgress = (trigger == null ? void 0 : trigger.trigger) === 'view-progress';
58
58
 
@@ -1 +1 @@
1
- {"version":3,"names":["CustomAnimation","AnimationGroup","getElement","getElementMotionPart","measure","mutate","getRanges","getNamedEffect","getEffectsData","fastdom","getWebAnimationEffect","preset","animation","target","options","type","duration","reducedMotion","iterations","undefined","domApi","HTMLElement","web","getWebAnimation","animationOptions","trigger","ownerDocument","element","effectOptions","customEffect","namedEffect","id","mouseAnimationPreset","mouseAnimationFactory","animationsData","data","effectId","timeline","isViewProgress","window","ViewTimeline","subject","componentId","animations","map","_ref","effect","part","effectTarget","keyframeEffect","KeyframeEffect","updateTiming","timing","setKeyframes","keyframes","timingOptions","Animation","start","end","rangeStart","rangeEnd","play","startOffset","endOffset","_offset","_offset2","startOffsetToWrite","endOffsetToWrite","Object","assign","name","offset","value","add","startOffsetAdd","endOffsetAdd","measured","Promise","resolve"],"sources":["../../../src/api/webAnimations.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationEffectAPI,\n AnimationOptions,\n MouseAnimationFactory,\n MouseAnimationInstance,\n ScrubAnimationOptions,\n TriggerVariant,\n WebAnimationEffectFactory,\n} from '../types';\nimport { CustomAnimation } from '../CustomAnimation';\nimport { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\n getElementMotionPart,\n measure,\n mutate,\n getRanges,\n getNamedEffect,\n getEffectsData,\n} from './common';\nimport fastdom from 'fastdom';\n\nfunction getWebAnimationEffect(\n preset: AnimationEffectAPI<any> | WebAnimationEffectFactory<any> | null,\n animation: AnimationOptions,\n target: HTMLElement | string | null,\n options?: Record<string, any>,\n): AnimationData[] | MouseAnimationFactory {\n if (preset) {\n // validate duration is a number over 0\n if (animation.type === 'TimeAnimationOptions') {\n animation.duration = animation.duration || 1;\n\n if (options?.reducedMotion) {\n if (animation.iterations === 1 || animation.iterations == undefined) {\n animation = { ...animation, duration: 1 };\n } else {\n return [];\n }\n }\n }\n\n let domApi;\n if (target instanceof HTMLElement) {\n domApi = { measure: measure(target), mutate: mutate(target) };\n }\n\n return (preset as AnimationEffectAPI<any>).web\n ? (preset as AnimationEffectAPI<any>).web(animation, domApi, options)\n : (preset as WebAnimationEffectFactory<any>)(animation, domApi, options);\n }\n\n return [];\n}\n\nfunction getWebAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n options?: Record<string, any>,\n ownerDocument?: Document,\n): AnimationGroup | MouseAnimationInstance {\n const element =\n target instanceof HTMLElement ? target : getElement(target, ownerDocument);\n\n if (trigger?.trigger === 'pointer-move') {\n let effectOptions = animationOptions;\n\n if (animationOptions.customEffect) {\n effectOptions = {\n ...animationOptions,\n namedEffect: { id: '', type: 'CustomMouse' },\n };\n }\n\n // TODO: need to fix the type here, currently lying about the returned type to be WebAnimationEffectFactory instead of MouseAnimationFactoryCreate\n const mouseAnimationPreset = getNamedEffect(\n effectOptions,\n ) as WebAnimationEffectFactory<'scrub'>;\n const mouseAnimationFactory = getWebAnimationEffect(\n mouseAnimationPreset,\n animationOptions,\n element,\n options,\n ) as MouseAnimationFactory;\n\n return mouseAnimationFactory(element as HTMLElement);\n }\n\n // get the preset for the given animation options\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n const animationsData = getWebAnimationEffect(\n namedEffect,\n animationOptions,\n element,\n options,\n ) as AnimationData[];\n const data = getEffectsData(animationsData, animationOptions.effectId);\n\n let timeline: typeof window.ViewTimeline | undefined;\n const isViewProgress = trigger?.trigger === 'view-progress';\n\n // if this is a ScrubAnimation with view-progress trigger and the browser supports the ViewTimeline API\n if (isViewProgress && window.ViewTimeline) {\n // generate the timeline object\n // @ts-expect-error\n timeline = new ViewTimeline({\n subject: trigger.element || getElement(trigger.componentId!),\n });\n }\n\n // generate an Animation object for each data object\n const animations = data.map(\n ({ effect, options: effectOptions, id, part }) => {\n const effectTarget = part ? getElementMotionPart(element, part) : element;\n\n const keyframeEffect = new KeyframeEffect(\n effectTarget || null,\n [],\n effectOptions,\n );\n\n // set the keyframes for the KeyframeEffect after measurements and mutations\n fastdom.mutate(() => {\n if ('timing' in effect) {\n keyframeEffect.updateTiming(effect.timing as OptionalEffectTiming);\n }\n\n keyframeEffect.setKeyframes(effect.keyframes);\n });\n\n const timingOptions =\n isViewProgress && timeline\n ? { timeline: timeline as AnimationTimeline }\n : {};\n const animation =\n typeof effect.customEffect === 'function'\n ? (new CustomAnimation(\n effect.customEffect,\n effectTarget || null,\n effectOptions,\n timingOptions,\n ) as Animation)\n : new Animation(keyframeEffect, timingOptions.timeline);\n\n // if this is a ScrubAnimation with view-progress trigger and the browser supports the ViewTimeline API\n if (isViewProgress) {\n if (timeline) {\n // set the ranges for the animation after measurements and mutations\n fastdom.mutate(() => {\n const { start, end } = getRanges(effect as AnimationDataForScrub);\n // @ts-expect-error\n animation.rangeStart = start;\n // @ts-expect-error\n animation.rangeEnd = end;\n\n animation.play();\n });\n } else {\n const { startOffset, endOffset } =\n animationOptions as ScrubAnimationOptions;\n\n // set the ranges for the animation after measurements and mutations\n fastdom.mutate(() => {\n const startOffsetToWrite =\n (effect as AnimationDataForScrub).startOffset || startOffset;\n const endOffsetToWrite =\n (effect as AnimationDataForScrub).endOffset || endOffset;\n\n Object.assign(animation, {\n start: {\n name: startOffsetToWrite!.name,\n offset: startOffsetToWrite!.offset?.value,\n add: (effect as AnimationDataForScrub)!.startOffsetAdd,\n },\n end: {\n name: endOffsetToWrite!.name,\n offset: endOffsetToWrite!.offset?.value,\n add: (effect as AnimationDataForScrub)!.endOffsetAdd,\n },\n });\n });\n }\n }\n\n if (id) {\n animation.id = id;\n }\n\n return animation;\n },\n );\n\n // create an AnimationGroup with the generate animations\n return new AnimationGroup(animations, {\n ...animationOptions,\n trigger: { ...(trigger || ({} as Partial<TriggerVariant>)) },\n // make sure the group is ready after all animation targets are measured and mutated\n measured: new Promise((resolve) => fastdom.mutate(resolve)),\n });\n}\n\nexport { getWebAnimation };\n"],"mappings":"AAWA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SACEC,UAAU,EACVC,oBAAoB,EACpBC,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,cAAc,QACT,UAAU;AACjB,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,qBAAqBA,CAC5BC,MAAuE,EACvEC,SAA2B,EAC3BC,MAAmC,EACnCC,OAA6B,EACY;EACzC,IAAIH,MAAM,EAAE;IACV;IACA,IAAIC,SAAS,CAACG,IAAI,KAAK,sBAAsB,EAAE;MAC7CH,SAAS,CAACI,QAAQ,GAAGJ,SAAS,CAACI,QAAQ,IAAI,CAAC;MAE5C,IAAIF,OAAO,YAAPA,OA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,IAAI,EAAEH,gBAAgB,CAAEG,IAAI;cAC5BC,MAAM,GAAAN,QAAA,GAAEE,gBAAgB,CAAEI,MAAM,qBAAxBN,QAAA,CAA0BO,KAAK;cACvCC,GAAG,EAAG3B,MAAM,CAA4B6B;YAC1C;UACF,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;IACF;IAEA,IAAI5C,EAAE,EAAE;MACNnB,SAAS,CAACmB,EAAE,GAAGA,EAAE;IACnB;IAEA,OAAOnB,SAAS;EAClB,CACF,CAAC;;EAED;EACA,OAAO,IAAIX,cAAc,CAAC0C,UAAU,EAAE;IACpC,GAAGnB,gBAAgB;IACnBC,OAAO,EAAE;MAAE,IAAIA,OAAO,IAAK,CAAC,CAA6B;IAAE,CAAC;IAC5D;IACAmD,QAAQ,EAAE,IAAIC,OAAO,CAAEC,OAAO,IAAKrE,OAAO,CAACJ,MAAM,CAACyE,OAAO,CAAC;EAC5D,CAAC,CAAC;AACJ;AAEA,SAASvD,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["CustomAnimation","AnimationGroup","getElement","getElementMotionPart","measure","mutate","getRanges","getNamedEffect","getEffectsData","isNotAScrubTrigger","fastdom","getWebAnimationEffect","preset","animation","target","trigger","options","duration","reducedMotion","iterations","undefined","domApi","HTMLElement","web","getWebAnimation","animationOptions","ownerDocument","element","effectOptions","customEffect","namedEffect","id","type","mouseAnimationPreset","mouseAnimationFactory","animationsData","data","effectId","timeline","isViewProgress","window","ViewTimeline","subject","componentId","animations","map","_ref","effect","part","effectTarget","keyframeEffect","KeyframeEffect","updateTiming","timing","setKeyframes","keyframes","timingOptions","Animation","start","end","rangeStart","rangeEnd","play","startOffset","endOffset","_offset","_offset2","startOffsetToWrite","endOffsetToWrite","Object","assign","name","offset","value","add","startOffsetAdd","endOffsetAdd","measured","Promise","resolve"],"sources":["../../../src/api/webAnimations.ts"],"sourcesContent":["import type {\n AnimationData,\n AnimationDataForScrub,\n AnimationEffectAPI,\n AnimationOptions,\n MouseAnimationFactory,\n MouseAnimationInstance,\n ScrubAnimationOptions,\n TriggerVariant,\n WebAnimationEffectFactory,\n} from '../types';\nimport { CustomAnimation } from '../CustomAnimation';\nimport { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\n getElementMotionPart,\n measure,\n mutate,\n getRanges,\n getNamedEffect,\n getEffectsData,\n isNotAScrubTrigger,\n} from './common';\nimport fastdom from 'fastdom';\n\nfunction getWebAnimationEffect(\n preset: AnimationEffectAPI<any> | WebAnimationEffectFactory<any> | null,\n animation: AnimationOptions,\n target: HTMLElement | string | null,\n trigger?: Partial<TriggerVariant>,\n options?: Record<string, any>,\n): AnimationData[] | MouseAnimationFactory {\n if (preset) {\n // validate duration is a number over 0\n if (isNotAScrubTrigger(trigger)) {\n animation.duration = animation.duration || 1;\n\n if (options?.reducedMotion) {\n if (animation.iterations === 1 || animation.iterations == undefined) {\n animation = { ...animation, duration: 1 };\n } else {\n return [];\n }\n }\n }\n\n let domApi;\n if (target instanceof HTMLElement) {\n domApi = { measure: measure(target), mutate: mutate(target) };\n }\n\n return (preset as AnimationEffectAPI<any>).web\n ? (preset as AnimationEffectAPI<any>).web(animation, domApi, options)\n : (preset as WebAnimationEffectFactory<any>)(animation, domApi, options);\n }\n\n return [];\n}\n\nfunction getWebAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n options?: Record<string, any>,\n ownerDocument?: Document,\n): AnimationGroup | MouseAnimationInstance {\n const element =\n target instanceof HTMLElement ? target : getElement(target, ownerDocument);\n\n if (trigger?.trigger === 'pointer-move') {\n let effectOptions = animationOptions;\n\n if (animationOptions.customEffect) {\n effectOptions = {\n ...animationOptions,\n namedEffect: { id: '', type: 'CustomMouse' },\n };\n }\n\n // TODO: need to fix the type here, currently lying about the returned type to be WebAnimationEffectFactory instead of MouseAnimationFactoryCreate\n const mouseAnimationPreset = getNamedEffect(\n effectOptions,\n ) as WebAnimationEffectFactory<'scrub'>;\n const mouseAnimationFactory = getWebAnimationEffect(\n mouseAnimationPreset,\n animationOptions,\n element,\n trigger,\n options,\n ) as MouseAnimationFactory;\n\n return mouseAnimationFactory(element as HTMLElement);\n }\n\n // get the preset for the given animation options\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n const animationsData = getWebAnimationEffect(\n namedEffect,\n animationOptions,\n element,\n trigger,\n options,\n ) as AnimationData[];\n const data = getEffectsData(\n animationsData,\n trigger,\n animationOptions.effectId,\n );\n\n let timeline: typeof window.ViewTimeline | undefined;\n const isViewProgress = trigger?.trigger === 'view-progress';\n\n // if this is a ScrubAnimation with view-progress trigger and the browser supports the ViewTimeline API\n if (isViewProgress && window.ViewTimeline) {\n // generate the timeline object\n // @ts-expect-error\n timeline = new ViewTimeline({\n subject: trigger.element || getElement(trigger.componentId!),\n });\n }\n\n // generate an Animation object for each data object\n const animations = data.map(\n ({ effect, options: effectOptions, id, part }) => {\n const effectTarget = part ? getElementMotionPart(element, part) : element;\n\n const keyframeEffect = new KeyframeEffect(\n effectTarget || null,\n [],\n effectOptions,\n );\n\n // set the keyframes for the KeyframeEffect after measurements and mutations\n fastdom.mutate(() => {\n if ('timing' in effect) {\n keyframeEffect.updateTiming(effect.timing as OptionalEffectTiming);\n }\n\n keyframeEffect.setKeyframes(effect.keyframes);\n });\n\n const timingOptions =\n isViewProgress && timeline\n ? { timeline: timeline as AnimationTimeline }\n : {};\n const animation: Animation | CustomAnimation =\n typeof effect.customEffect === 'function'\n ? (new CustomAnimation(\n effect.customEffect,\n effectTarget || null,\n effectOptions,\n timingOptions,\n ) as Animation)\n : new Animation(keyframeEffect, timingOptions.timeline);\n\n // if this is a ScrubAnimation with view-progress trigger and the browser supports the ViewTimeline API\n if (isViewProgress) {\n if (timeline) {\n // set the ranges for the animation after measurements and mutations\n fastdom.mutate(() => {\n const { start, end } = getRanges(effect as AnimationDataForScrub);\n // @ts-expect-error\n animation.rangeStart = start;\n // @ts-expect-error\n animation.rangeEnd = end;\n\n animation.play();\n });\n } else {\n const { startOffset, endOffset } =\n animationOptions as ScrubAnimationOptions;\n\n // set the ranges for the animation after measurements and mutations\n fastdom.mutate(() => {\n const startOffsetToWrite =\n (effect as AnimationDataForScrub).startOffset || startOffset;\n const endOffsetToWrite =\n (effect as AnimationDataForScrub).endOffset || endOffset;\n\n Object.assign(animation, {\n start: {\n name: startOffsetToWrite!.name,\n offset: startOffsetToWrite!.offset?.value,\n add: (effect as AnimationDataForScrub)!.startOffsetAdd,\n },\n end: {\n name: endOffsetToWrite!.name,\n offset: endOffsetToWrite!.offset?.value,\n add: (effect as AnimationDataForScrub)!.endOffsetAdd,\n },\n });\n });\n }\n }\n\n if (id) {\n animation.id = id;\n }\n\n return animation;\n },\n );\n\n // create an AnimationGroup with the generate animations\n return new AnimationGroup(animations, {\n ...animationOptions,\n trigger: { ...(trigger || ({} as Partial<TriggerVariant>)) },\n // make sure the group is ready after all animation targets are measured and mutated\n measured: new Promise((resolve) => fastdom.mutate(resolve)),\n });\n}\n\nexport { getWebAnimation };\n"],"mappings":"AAWA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SACEC,UAAU,EACVC,oBAAoB,EACpBC,OAAO,EACPC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,cAAc,EACdC,kBAAkB,QACb,UAAU;AACjB,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,qBAAqBA,CAC5BC,MAAuE,EACvEC,SAA2B,EAC3BC,MAAmC,EACnCC,OAAiC,EACjCC,OAA6B,EACY;EACzC,IAAIJ,MAAM,EAAE;IACV;IACA,IAAIH,kBAAkB,CAACM,OAAO,CAAC,EAAE;MAC/BF,SAAS,CAACI,QAAQ,GAAGJ,SAAS,CAACI,QAAQ,IAAI,CAAC;MAE5C,IAAID,OAAO,YAAPA,OAAO,CAAEE,aAAa,EAAE;QAC1B,IAAIL,SAAS,CAACM,UAAU,KAAK,CAAC,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AI;cAC5BC,MAAM,GAAAN,QAAA,GAAEE,gBAAgB,CAAEI,MAAM,qBAAxBN,QAAA,CAA0BO,KAAK;cACvCC,GAAG,EAAG3B,MAAM,CAA4B6B;YAC1C;UACF,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;IACF;IAEA,IAAI7C,EAAE,EAAE;MACNlB,SAAS,CAACkB,EAAE,GAAGA,EAAE;IACnB;IAEA,OAAOlB,SAAS;EAClB,CACF,CAAC;;EAED;EACA,OAAO,IAAIZ,cAAc,CAAC2C,UAAU,EAAE;IACpC,GAAGnB,gBAAgB;IACnBV,OAAO,EAAE;MAAE,IAAIA,OAAO,IAAK,CAAC,CAA6B;IAAE,CAAC;IAC5D;IACA8D,QAAQ,EAAE,IAAIC,OAAO,CAAEC,OAAO,IAAKrE,OAAO,CAACL,MAAM,CAAC0E,OAAO,CAAC;EAC5D,CAAC,CAAC;AACJ;AAEA,SAASvD,eAAe","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  export const baseMockOptions = {
2
- id: '1',
3
- type: 'ScrubAnimationOptions'
2
+ id: '1'
4
3
  };
5
4
  //# sourceMappingURL=testUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["baseMockOptions","id","type"],"sources":["../../../../../src/library/backgroundScroll/test/testUtils.ts"],"sourcesContent":["import type { ScrubAnimationOptions } from '../../../types';\n\nexport const baseMockOptions: ScrubAnimationOptions = {\n id: '1',\n type: 'ScrubAnimationOptions',\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAsC,GAAG;EACpDC,EAAE,EAAE,GAAG;EACPC,IAAI,EAAE;AACR,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["baseMockOptions","id"],"sources":["../../../../../src/library/backgroundScroll/test/testUtils.ts"],"sourcesContent":["import type { ScrubAnimationOptions } from '../../../types';\n\nexport const baseMockOptions: ScrubAnimationOptions = {\n id: '1',\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAsC,GAAG;EACpDC,EAAE,EAAE;AACN,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  export const baseMockOptions = {
2
- id: '1',
3
- type: 'TimeAnimationOptions'
2
+ id: '1'
4
3
  };
5
4
  //# sourceMappingURL=testUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["baseMockOptions","id","type"],"sources":["../../../../../src/library/entrance/test/testUtils.ts"],"sourcesContent":["import type { TimeAnimationOptions } from '../../../types';\n\nexport const baseMockOptions: TimeAnimationOptions = {\n id: '1',\n type: 'TimeAnimationOptions',\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAqC,GAAG;EACnDC,EAAE,EAAE,GAAG;EACPC,IAAI,EAAE;AACR,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["baseMockOptions","id"],"sources":["../../../../../src/library/entrance/test/testUtils.ts"],"sourcesContent":["import type { TimeAnimationOptions } from '../../../types';\n\nexport const baseMockOptions: TimeAnimationOptions = {\n id: '1',\n};\n"],"mappings":"AAEA,OAAO,MAAMA,eAAqC,GAAG;EACnDC,EAAE,EAAE;AACN,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  export const baseMockOptions = {
2
- id: 'test-id',
3
- type: 'TimeAnimationOptions'
2
+ id: 'test-id'
4
3
  };
5
4
  //# sourceMappingURL=testUtils.js.map