@wix/motion 1.604.0 → 1.605.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.
@@ -8,6 +8,20 @@ var _common = require("./common");
8
8
  var _fastdom = _interopRequireDefault(require("fastdom"));
9
9
  function getWebAnimationEffect(preset, animation, target, options) {
10
10
  if (preset) {
11
+ // validate duration is a number over 0
12
+ if (animation.type === 'TimeAnimationOptions') {
13
+ animation.duration = animation.duration || 1;
14
+ if (options != null && options.reducedMotion) {
15
+ if (animation.iterations === 1 || animation.iterations == undefined) {
16
+ animation = {
17
+ ...animation,
18
+ duration: 1
19
+ };
20
+ } else {
21
+ return [];
22
+ }
23
+ }
24
+ }
11
25
  let domApi;
12
26
  if (target instanceof HTMLElement) {
13
27
  domApi = {
@@ -15,11 +29,6 @@ function getWebAnimationEffect(preset, animation, target, options) {
15
29
  mutate: (0, _common.mutate)(target)
16
30
  };
17
31
  }
18
-
19
- // validate duration is a number over 0
20
- if (animation.type === 'TimeAnimationOptions') {
21
- animation.duration = animation.duration || 1;
22
- }
23
32
  return preset.web ? preset.web(animation, domApi, options) : preset(animation, domApi, options);
24
33
  }
25
34
  return [];
@@ -1 +1 @@
1
- {"version":3,"names":["_AnimationGroup","require","_common","_fastdom","_interopRequireDefault","getWebAnimationEffect","preset","animation","target","options","domApi","HTMLElement","measure","mutate","type","duration","web","getWebAnimation","animationOptions","trigger","ownerDocument","element","getElement","effectOptions","customEffect","namedEffect","id","mouseAnimationPreset","getNamedEffect","mouseAnimationFactory","animationsData","data","getEffectsData","effectId","timeline","isViewProgress","window","ViewTimeline","subject","componentId","animations","map","effect","part","effectTarget","querySelector","keyframeEffect","KeyframeEffect","fastdom","updateTiming","timing","setKeyframes","keyframes","Animation","start","end","getRanges","rangeStart","rangeEnd","play","startOffset","endOffset","_offset","_offset2","startOffsetToWrite","endOffsetToWrite","Object","assign","name","offset","value","add","startOffsetAdd","endOffsetAdd","AnimationGroup","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 { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\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 let domApi;\n if (target instanceof HTMLElement) {\n domApi = { measure: measure(target), mutate: mutate(target) };\n }\n\n // validate duration is a number over 0\n if (animation.type === 'TimeAnimationOptions') {\n animation.duration = animation.duration || 1;\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\n ? element?.querySelector(`[data-motion-part~=\"${part}\"]`) // maybe add ~ here as well\n : 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 animation: Animation =\n isViewProgress && timeline\n ? new Animation(keyframeEffect, timeline as AnimationTimeline)\n : new Animation(keyframeEffect);\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,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,SAASI,qBAAqBA,CAC5BC,MAAuE,EACvEC,SAA2B,EAC3BC,MAAmC,EACnCC,OAA6B,EACY;EACzC,IAAIH,MAAM,EAAE;IACV,IAAII,MAAM;IACV,IAAIF,MAAM,YAAYG,WAAW,EAAE;MACjCD,MAAM,GAAG;QAAEE,OAAO,EAAE,IAAAA,eAAO,EAACJ,MAAM,CAAC;QAAEK,MAAM,EAAE,IAAAA,cAAM,EAACL,MAAM;MAAE,CAAC;IAC/D;;IAEA;IACA,IAAID,SAAS,CAACO,IAAI,KAAK,sBAAsB,EAAE;MAC7CP,SAAS,CAACQ,QAAQ,GAAGR,SAAS,CAACQ,QAAQ,IAAI,CAAC;IAC9C;IAEA,OAAQT,MAAM,CAA6BU,GAAG,GACzCV,MAAM,CAA6BU,GAAG,CAACT,SAAS,EAAEG,MAAM,EAAED,OAAO,CAAC,GAClEH,MAAM,CAAoCC,SAAS,EAAEG,MAAM,EAAED,OAAO,CAAC;EAC5E;EAEA,OAAO,EAAE;AACX;A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CAACnC,MAAM,CAAC,MAAM;UAAA,IAAAiD,OAAA,EAAAC,QAAA;UACnB,MAAMC,kBAAkB,GACrBtB,MAAM,CAA2BkB,WAAW,IAAIA,WAAW;UAC9D,MAAMK,gBAAgB,GACnBvB,MAAM,CAA2BmB,SAAS,IAAIA,SAAS;UAE1DK,MAAM,CAACC,MAAM,CAAC5D,SAAS,EAAE;YACvB+C,KAAK,EAAE;cACLc,IAAI,EAAEJ,kBAAkB,CAAEI,IAAI;cAC9BC,MAAM,GAAAP,OAAA,GAAEE,kBAAkB,CAAEK,MAAM,qBAA1BP,OAAA,CAA4BQ,KAAK;cACzCC,GAAG,EAAG7B,MAAM,CAA4B8B;YAC1C,CAAC;YACDjB,GAAG,EAAE;cACHa,IAAI,EAAEH,gBAAgB,CAAEG,IAAI;cAC5BC,MAAM,GAAAN,QAAA,GAAEE,gBAAgB,CAAEI,MAAM,qBAAxBN,QAAA,CAA0BO,KAAK;cACvCC,GAAG,EAAG7B,MAAM,CAA4B+B;YAC1C;UACF,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;IACF;IAEA,IAAI/C,EAAE,EAAE;MACNnB,SAAS,CAACmB,EAAE,GAAGA,EAAE;IACnB;IAEA,OAAOnB,SAAS;EAClB,CACF,CAAC;;EAED;EACA,OAAO,IAAImE,8BAAc,CAAClC,UAAU,EAAE;IACpC,GAAGtB,gBAAgB;IACnBC,OAAO,EAAE;MAAE,IAAIA,OAAO,IAAK,CAAC,CAA6B;IAAE,CAAC;IAC5D;IACAwD,QAAQ,EAAE,IAAIC,OAAO,CAAEC,OAAO,IAAK7B,gBAAO,CAACnC,MAAM,CAACgE,OAAO,CAAC;EAC5D,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_AnimationGroup","require","_common","_fastdom","_interopRequireDefault","getWebAnimationEffect","preset","animation","target","options","type","duration","reducedMotion","iterations","undefined","domApi","HTMLElement","measure","mutate","web","getWebAnimation","animationOptions","trigger","ownerDocument","element","getElement","effectOptions","customEffect","namedEffect","id","mouseAnimationPreset","getNamedEffect","mouseAnimationFactory","animationsData","data","getEffectsData","effectId","timeline","isViewProgress","window","ViewTimeline","subject","componentId","animations","map","effect","part","effectTarget","querySelector","keyframeEffect","KeyframeEffect","fastdom","updateTiming","timing","setKeyframes","keyframes","Animation","start","end","getRanges","rangeStart","rangeEnd","play","startOffset","endOffset","_offset","_offset2","startOffsetToWrite","endOffsetToWrite","Object","assign","name","offset","value","add","startOffsetAdd","endOffsetAdd","AnimationGroup","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 { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\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\n ? element?.querySelector(`[data-motion-part~=\"${part}\"]`) // maybe add ~ here as well\n : 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 animation: Animation =\n isViewProgress && timeline\n ? new Animation(keyframeEffect, timeline as AnimationTimeline)\n : new Animation(keyframeEffect);\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,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAQA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,SAASI,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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AAgB,CAAEI,MAAM,qBAAxBN,QAAA,CAA0BO,KAAK;cACvCC,GAAG,EAAG7B,MAAM,CAA4B+B;YAC1C;UACF,CAAC,CAAC;QACJ,CAAC,CAAC;MACJ;IACF;IAEA,IAAI/C,EAAE,EAAE;MACNtB,SAAS,CAACsB,EAAE,GAAGA,EAAE;IACnB;IAEA,OAAOtB,SAAS;EAClB,CACF,CAAC;;EAED;EACA,OAAO,IAAIsE,8BAAc,CAAClC,UAAU,EAAE;IACpC,GAAGtB,gBAAgB;IACnBC,OAAO,EAAE;MAAE,IAAIA,OAAO,IAAK,CAAC,CAA6B;IAAE,CAAC;IAC5D;IACAwD,QAAQ,EAAE,IAAIC,OAAO,CAAEC,OAAO,IAAK7B,gBAAO,CAACjC,MAAM,CAAC8D,OAAO,CAAC;EAC5D,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -128,7 +128,7 @@ function getScrubScene(target, animationOptions, trigger, sceneOptions = {}) {
128
128
  }
129
129
  };
130
130
  }
131
- function getAnimation(target, animationOptions, trigger) {
131
+ function getAnimation(target, animationOptions, trigger, reducedMotion = false) {
132
132
  const animation = getElementCSSAnimation(target, animationOptions);
133
133
  if (animation) {
134
134
  animation.ready = new Promise(resolve => {
@@ -136,6 +136,8 @@ function getAnimation(target, animationOptions, trigger) {
136
136
  });
137
137
  return animation;
138
138
  }
139
- return (0, _webAnimations.getWebAnimation)(target, animationOptions, trigger);
139
+ return (0, _webAnimations.getWebAnimation)(target, animationOptions, trigger, {
140
+ reducedMotion
141
+ });
140
142
  }
141
143
  //# sourceMappingURL=motion.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_AnimationGroup","require","_utils","exports","getEasing","_webAnimations","getWebAnimation","_cssAnimations","getCSSAnimation","_prepare","prepareAnimation","_common","getElementCSSAnimation","target","animationOptions","namedEffect","getNamedEffect","style","effectId","getElementAnimation","effectNames","getNames","element","getElement","animations","getAnimations","animationNames","map","anim","animationName","filteredAnimations","forEach","name","includes","push","find","length","AnimationGroup","filter","id","startsWith","getScrubScene","trigger","sceneOptions","disabled","allowActiveEvent","rest","animation","typeSpecificOptions","window","ViewTimeline","viewSource","componentId","ready","partialAnimation","start","end","getProgress","effect","__","p","activeDuration","getComputedTiming","delay","getTiming","currentTime","destroy","cancel","centeredToTarget","transitionDuration","transitionEasing","customEffect","getJsEasing","v","active","progress","getAnimation","Promise","resolve"],"sources":["../../src/motion.ts"],"sourcesContent":["import type {\n AnimationOptions,\n ScrubAnimationOptions,\n TriggerVariant,\n MouseAnimationInstance,\n AnimationEffectAPI,\n CustomMouseAnimationInstance,\n ScrubScrollScene,\n ScrubPointerScene,\n} from './types';\nimport { AnimationGroup } from './AnimationGroup';\nimport { getEasing, getJsEasing } from './utils';\nimport { getWebAnimation } from './api/webAnimations';\nimport { getCSSAnimation } from './api/cssAnimations';\nimport { prepareAnimation } from './api/prepare';\nimport { getElement, getNamedEffect } from './api/common';\n\nfunction getElementCSSAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n): AnimationGroup | null {\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n if (!namedEffect) {\n return null;\n }\n\n if (!namedEffect.style) {\n // if this named effect does not have a style method, attempt to get group of Web Animations\n if (animationOptions.effectId && target) {\n return getElementAnimation(target, animationOptions.effectId);\n }\n\n return null;\n }\n\n const effectNames = namedEffect.getNames(animationOptions);\n const element = typeof target === 'string' ? getElement(target) : target;\n const animations = element?.getAnimations();\n const animationNames =\n animations?.map((anim) => (anim as CSSAnimation).animationName) ||\n ([] as string[]);\n const filteredAnimations: CSSAnimation[] = [];\n\n effectNames.forEach((name) => {\n if (animationNames.includes(name)) {\n filteredAnimations.push(\n animations?.find(\n (anim) => (anim as CSSAnimation).animationName === name,\n ) as CSSAnimation,\n );\n }\n });\n\n return filteredAnimations?.length\n ? new AnimationGroup(filteredAnimations)\n : null;\n}\n\nfunction getElementAnimation(\n target: HTMLElement | string,\n effectId: string,\n): AnimationGroup | null {\n const element = typeof target === 'string' ? getElement(target) : target;\n // somehow get the right animations\n const animations = element\n ?.getAnimations()\n .filter((anim: Animation | CSSAnimation) => {\n const id = anim.id || (anim as CSSAnimation).animationName;\n // if no id/name just return all animations\n return id ? id.startsWith(effectId) : true;\n });\n\n return animations?.length ? new AnimationGroup(animations) : null;\n}\n\nfunction getScrubScene(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger: Partial<TriggerVariant> & { element?: HTMLElement },\n sceneOptions: Record<string, any> = {},\n): ScrubScrollScene[] | ScrubPointerScene {\n const { disabled, allowActiveEvent, ...rest } = sceneOptions;\n const animation = getWebAnimation(target, animationOptions, trigger, rest);\n\n let typeSpecificOptions = {} as Record<string, any>;\n\n if (trigger.trigger === 'view-progress' && !window.ViewTimeline) {\n // TODO(ameerf): consider doing this only for bgscrub to not affect the other scroll effects\n const viewSource = trigger.element || getElement(trigger.componentId!);\n const { ready } = animation as AnimationGroup;\n\n return (animation as AnimationGroup).animations.map((partialAnimation) => {\n return {\n /* we use getters for start and end in order to access the animation's start and end\n only when initializing the scrub scene rather than immediately */\n get start() {\n return partialAnimation.start;\n },\n get end() {\n return partialAnimation.end;\n },\n viewSource,\n ready,\n getProgress() {\n return (animation as AnimationGroup).getProgress();\n },\n effect(__: any, p: number) {\n const { activeDuration } =\n partialAnimation.effect!.getComputedTiming();\n const { delay } = partialAnimation.effect!.getTiming();\n\n partialAnimation.currentTime =\n ((delay || 0) + ((activeDuration as number) || 0)) * p;\n },\n disabled,\n destroy() {\n partialAnimation.cancel();\n },\n } as ScrubScrollScene;\n });\n } else if (trigger.trigger === 'pointer-move') {\n const { centeredToTarget, transitionDuration, transitionEasing } =\n animationOptions as ScrubAnimationOptions;\n\n typeSpecificOptions = {\n target: (animation as MouseAnimationInstance).target,\n centeredToTarget,\n allowActiveEvent,\n };\n\n if (animationOptions.customEffect && transitionDuration) {\n typeSpecificOptions.transitionDuration = transitionDuration;\n typeSpecificOptions.transitionEasing = getJsEasing(transitionEasing);\n }\n }\n\n return {\n ...typeSpecificOptions,\n getProgress() {\n return (\n animation as AnimationGroup | CustomMouseAnimationInstance\n ).getProgress();\n },\n effect(\n __: any,\n p: number | { x: number; y: number },\n v?: { x: number; y: number },\n active?: boolean,\n ) {\n animation.progress(\n v\n ? {\n // @ts-expect-error spread error on p\n ...p,\n v,\n active,\n }\n : p,\n );\n },\n disabled,\n destroy() {\n animation.cancel();\n },\n } as ScrubPointerScene;\n}\n\nfunction getAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n): AnimationGroup | MouseAnimationInstance | null {\n const animation = getElementCSSAnimation(target, animationOptions);\n\n if (animation) {\n animation.ready = new Promise((resolve) => {\n prepareAnimation(target, animationOptions, resolve);\n });\n\n return animation;\n }\n\n return getWebAnimation(\n target,\n animationOptions,\n trigger,\n );\n}\n\nexport {\n getCSSAnimation,\n getWebAnimation,\n getElementCSSAnimation,\n getElementAnimation,\n getScrubScene,\n prepareAnimation,\n getAnimation,\n getEasing,\n};\n\nexport type { AnimationGroup };\n"],"mappings":";;;;;;;AAUA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAiDE,OAAA,CAAAC,SAAA,GAAAF,MAAA,CAAAE,SAAA;AACjD,IAAAC,cAAA,GAAAJ,OAAA;AAAsDE,OAAA,CAAAG,eAAA,GAAAD,cAAA,CAAAC,eAAA;AACtD,IAAAC,cAAA,GAAAN,OAAA;AAAsDE,OAAA,CAAAK,eAAA,GAAAD,cAAA,CAAAC,eAAA;AACtD,IAAAC,QAAA,GAAAR,OAAA;AAAiDE,OAAA,CAAAO,gBAAA,GAAAD,QAAA,CAAAC,gBAAA;AACjD,IAAAC,OAAA,GAAAV,OAAA;AAEA,SAASW,sBAAsBA,CAC7BC,MAAmC,EACnCC,gBAAkC,EACX;EACvB,MAAMC,WAAW,GAAG,IAAAC,sBAAc,EAChCF,gBACF,CAAm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;IACH,CAAC;IACDhB,QAAQ;IACRsB,OAAOA,CAAA,EAAG;MACRnB,SAAS,CAACoB,MAAM,CAAC,CAAC;IACpB;EACF,CAAC;AACH;AAEA,SAASS,YAAYA,CACnB/D,MAAmC,EACnCC,gBAAkC,EAClC4B,OAA6D,EACb;EAChD,MAAMK,SAAS,GAAGnC,sBAAsB,CAACC,MAAM,EAAEC,gBAAgB,CAAC;EAElE,IAAIiC,SAAS,EAAE;IACbA,SAAS,CAACM,KAAK,GAAG,IAAIwB,OAAO,CAAEC,OAAO,IAAK;MACzC,IAAApE,yBAAgB,EAACG,MAAM,EAAEC,gBAAgB,EAAEgE,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO/B,SAAS;EAClB;EAEA,OAAO,IAAAzC,8BAAe,EACpBO,MAAM,EACNC,gBAAgB,EAChB4B,OACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_AnimationGroup","require","_utils","exports","getEasing","_webAnimations","getWebAnimation","_cssAnimations","getCSSAnimation","_prepare","prepareAnimation","_common","getElementCSSAnimation","target","animationOptions","namedEffect","getNamedEffect","style","effectId","getElementAnimation","effectNames","getNames","element","getElement","animations","getAnimations","animationNames","map","anim","animationName","filteredAnimations","forEach","name","includes","push","find","length","AnimationGroup","filter","id","startsWith","getScrubScene","trigger","sceneOptions","disabled","allowActiveEvent","rest","animation","typeSpecificOptions","window","ViewTimeline","viewSource","componentId","ready","partialAnimation","start","end","getProgress","effect","__","p","activeDuration","getComputedTiming","delay","getTiming","currentTime","destroy","cancel","centeredToTarget","transitionDuration","transitionEasing","customEffect","getJsEasing","v","active","progress","getAnimation","reducedMotion","Promise","resolve"],"sources":["../../src/motion.ts"],"sourcesContent":["import type {\n AnimationOptions,\n ScrubAnimationOptions,\n TriggerVariant,\n MouseAnimationInstance,\n AnimationEffectAPI,\n CustomMouseAnimationInstance,\n ScrubScrollScene,\n ScrubPointerScene,\n} from './types';\nimport { AnimationGroup } from './AnimationGroup';\nimport { getEasing, getJsEasing } from './utils';\nimport { getWebAnimation } from './api/webAnimations';\nimport { getCSSAnimation } from './api/cssAnimations';\nimport { prepareAnimation } from './api/prepare';\nimport { getElement, getNamedEffect } from './api/common';\n\nfunction getElementCSSAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n): AnimationGroup | null {\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n if (!namedEffect) {\n return null;\n }\n\n if (!namedEffect.style) {\n // if this named effect does not have a style method, attempt to get group of Web Animations\n if (animationOptions.effectId && target) {\n return getElementAnimation(target, animationOptions.effectId);\n }\n\n return null;\n }\n\n const effectNames = namedEffect.getNames(animationOptions);\n const element = typeof target === 'string' ? getElement(target) : target;\n const animations = element?.getAnimations();\n const animationNames =\n animations?.map((anim) => (anim as CSSAnimation).animationName) ||\n ([] as string[]);\n const filteredAnimations: CSSAnimation[] = [];\n\n effectNames.forEach((name) => {\n if (animationNames.includes(name)) {\n filteredAnimations.push(\n animations?.find(\n (anim) => (anim as CSSAnimation).animationName === name,\n ) as CSSAnimation,\n );\n }\n });\n\n return filteredAnimations?.length\n ? new AnimationGroup(filteredAnimations)\n : null;\n}\n\nfunction getElementAnimation(\n target: HTMLElement | string,\n effectId: string,\n): AnimationGroup | null {\n const element = typeof target === 'string' ? getElement(target) : target;\n // somehow get the right animations\n const animations = element\n ?.getAnimations()\n .filter((anim: Animation | CSSAnimation) => {\n const id = anim.id || (anim as CSSAnimation).animationName;\n // if no id/name just return all animations\n return id ? id.startsWith(effectId) : true;\n });\n\n return animations?.length ? new AnimationGroup(animations) : null;\n}\n\nfunction getScrubScene(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger: Partial<TriggerVariant> & { element?: HTMLElement },\n sceneOptions: Record<string, any> = {},\n): ScrubScrollScene[] | ScrubPointerScene {\n const { disabled, allowActiveEvent, ...rest } = sceneOptions;\n const animation = getWebAnimation(target, animationOptions, trigger, rest);\n\n let typeSpecificOptions = {} as Record<string, any>;\n\n if (trigger.trigger === 'view-progress' && !window.ViewTimeline) {\n // TODO(ameerf): consider doing this only for bgscrub to not affect the other scroll effects\n const viewSource = trigger.element || getElement(trigger.componentId!);\n const { ready } = animation as AnimationGroup;\n\n return (animation as AnimationGroup).animations.map((partialAnimation) => {\n return {\n /* we use getters for start and end in order to access the animation's start and end\n only when initializing the scrub scene rather than immediately */\n get start() {\n return partialAnimation.start;\n },\n get end() {\n return partialAnimation.end;\n },\n viewSource,\n ready,\n getProgress() {\n return (animation as AnimationGroup).getProgress();\n },\n effect(__: any, p: number) {\n const { activeDuration } =\n partialAnimation.effect!.getComputedTiming();\n const { delay } = partialAnimation.effect!.getTiming();\n\n partialAnimation.currentTime =\n ((delay || 0) + ((activeDuration as number) || 0)) * p;\n },\n disabled,\n destroy() {\n partialAnimation.cancel();\n },\n } as ScrubScrollScene;\n });\n } else if (trigger.trigger === 'pointer-move') {\n const { centeredToTarget, transitionDuration, transitionEasing } =\n animationOptions as ScrubAnimationOptions;\n\n typeSpecificOptions = {\n target: (animation as MouseAnimationInstance).target,\n centeredToTarget,\n allowActiveEvent,\n };\n\n if (animationOptions.customEffect && transitionDuration) {\n typeSpecificOptions.transitionDuration = transitionDuration;\n typeSpecificOptions.transitionEasing = getJsEasing(transitionEasing);\n }\n }\n\n return {\n ...typeSpecificOptions,\n getProgress() {\n return (\n animation as AnimationGroup | CustomMouseAnimationInstance\n ).getProgress();\n },\n effect(\n __: any,\n p: number | { x: number; y: number },\n v?: { x: number; y: number },\n active?: boolean,\n ) {\n animation.progress(\n v\n ? {\n // @ts-expect-error spread error on p\n ...p,\n v,\n active,\n }\n : p,\n );\n },\n disabled,\n destroy() {\n animation.cancel();\n },\n } as ScrubPointerScene;\n}\n\nfunction getAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n reducedMotion: boolean = false,\n): AnimationGroup | MouseAnimationInstance | null {\n const animation = getElementCSSAnimation(target, animationOptions);\n\n if (animation) {\n animation.ready = new Promise((resolve) => {\n prepareAnimation(target, animationOptions, resolve);\n });\n\n return animation;\n }\n\n return getWebAnimation(target, animationOptions, trigger, { reducedMotion });\n}\n\nexport {\n getCSSAnimation,\n getWebAnimation,\n getElementCSSAnimation,\n getElementAnimation,\n getScrubScene,\n prepareAnimation,\n getAnimation,\n getEasing,\n};\n\nexport type { AnimationGroup };\n"],"mappings":";;;;;;;AAUA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAiDE,OAAA,CAAAC,SAAA,GAAAF,MAAA,CAAAE,SAAA;AACjD,IAAAC,cAAA,GAAAJ,OAAA;AAAsDE,OAAA,CAAAG,eAAA,GAAAD,cAAA,CAAAC,eAAA;AACtD,IAAAC,cAAA,GAAAN,OAAA;AAAsDE,OAAA,CAAAK,eAAA,GAAAD,cAAA,CAAAC,eAAA;AACtD,IAAAC,QAAA,GAAAR,OAAA;AAAiDE,OAAA,CAAAO,gBAAA,GAAAD,QAAA,CAAAC,gBAAA;AACjD,IAAAC,OAAA,GAAAV,OAAA;AAEA,SAASW,sBAAsBA,CAC7BC,MAAmC,EACnCC,gBAAkC,EACX;EACvB,MAAMC,WAAW,GAAG,IAAAC,sBAAc,EAChCF,gBACF,CAAmC;EAEnC,IAAI,CAACC,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,IAAI,CAACA,WAAW,CAACE,KAAK,EAAE;IACtB;IACA,IAAIH,gBAAgB,CAACI,QAAQ,IAAIL,MAAM,EAAE;MACvC,OAAOM,mBAAmB,CAACN,MAAM,EAAEC,gBAAgB,CAACI,QAAQ,CAAC;IAC/D;IAEA,OAAO,IAAI;EACb;EAEA,MAAME,WAAW,GAAGL,WAAW,CAACM,QAAQ,CAACP,gBAAgB,CAAC;EAC1D,MAAMQ,OAAO,GAAG,OAAOT,MAAM,KAAK,QAAQ,GAAG,IAAAU,kBAAU,EAACV,MAAM,CAAC,GAAGA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AgB,EAAEiE,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAOhC,SAAS;EAClB;EAEA,OAAO,IAAAzC,8BAAe,EAACO,MAAM,EAAEC,gBAAgB,EAAE4B,OAAO,EAAE;IAAEmC;EAAc,CAAC,CAAC;AAC9E","ignoreList":[]}
@@ -3,6 +3,20 @@ import { getElement, measure, mutate, getRanges, getNamedEffect, getEffectsData
3
3
  import fastdom from 'fastdom';
4
4
  function getWebAnimationEffect(preset, animation, target, options) {
5
5
  if (preset) {
6
+ // validate duration is a number over 0
7
+ if (animation.type === 'TimeAnimationOptions') {
8
+ animation.duration = animation.duration || 1;
9
+ if (options != null && options.reducedMotion) {
10
+ if (animation.iterations === 1 || animation.iterations == undefined) {
11
+ animation = {
12
+ ...animation,
13
+ duration: 1
14
+ };
15
+ } else {
16
+ return [];
17
+ }
18
+ }
19
+ }
6
20
  let domApi;
7
21
  if (target instanceof HTMLElement) {
8
22
  domApi = {
@@ -10,11 +24,6 @@ function getWebAnimationEffect(preset, animation, target, options) {
10
24
  mutate: mutate(target)
11
25
  };
12
26
  }
13
-
14
- // validate duration is a number over 0
15
- if (animation.type === 'TimeAnimationOptions') {
16
- animation.duration = animation.duration || 1;
17
- }
18
27
  return preset.web ? preset.web(animation, domApi, options) : preset(animation, domApi, options);
19
28
  }
20
29
  return [];
@@ -1 +1 @@
1
- {"version":3,"names":["AnimationGroup","getElement","measure","mutate","getRanges","getNamedEffect","getEffectsData","fastdom","getWebAnimationEffect","preset","animation","target","options","domApi","HTMLElement","type","duration","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","querySelector","keyframeEffect","KeyframeEffect","updateTiming","timing","setKeyframes","keyframes","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 { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\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 let domApi;\n if (target instanceof HTMLElement) {\n domApi = { measure: measure(target), mutate: mutate(target) };\n }\n\n // validate duration is a number over 0\n if (animation.type === 'TimeAnimationOptions') {\n animation.duration = animation.duration || 1;\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\n ? element?.querySelector(`[data-motion-part~=\"${part}\"]`) // maybe add ~ here as well\n : 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 animation: Animation =\n isViewProgress && timeline\n ? new Animation(keyframeEffect, timeline as AnimationTimeline)\n : new Animation(keyframeEffect);\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,cAAc,QAAQ,mBAAmB;AAClD,SACEC,UAAU,EACVC,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,IAAII,MAAM;IACV,IAAIF,MAAM,YAAYG,WAAW,EAAE;MACjCD,MAAM,GAAG;QAAEX,OAAO,EAAEA,OAAO,CAACS,MAAM,CAAC;QAAER,MAAM,EAAEA,MAAM,CAACQ,MAAM;MAAE,CAAC;IAC/D;;IAEA;IACA,IAAID,SAAS,CAACK,IAAI,KAAK,sBAAsB,EAAE;MAC7CL,SAAS,CAACM,QAAQ,GAAGN,SAAS,CAACM,QAAQ,IAAI,CAAC;IAC9C;IAEA,OAAQP,MAAM,CAA6BQ,GAAG,GACzCR,MAAM,CAA6BQ,GAAG,CAACP,SAAS,EAAEG,MAAM,EAAED,OAAO,CAAC,GAClEH,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AM;UAAEC,WAAW;UAAEC;QAAU,CAAC,GAC9BvC,gBAAyC;;QAE3C;QACAZ,OAAO,CAACJ,MAAM,CAAC,MAAM;UAAA,IAAAwD,OAAA,EAAAC,QAAA;UACnB,MAAMC,kBAAkB,GACrBpB,MAAM,CAA2BgB,WAAW,IAAIA,WAAW;UAC9D,MAAMK,gBAAgB,GACnBrB,MAAM,CAA2BiB,SAAS,IAAIA,SAAS;UAE1DK,MAAM,CAACC,MAAM,CAACtD,SAAS,EAAE;YACvB0C,KAAK,EAAE;cACLa,IAAI,EAAEJ,kBAAkB,CAAEI,IAAI;cAC9BC,MAAM,GAAAP,OAAA,GAAEE,kBAAkB,CAAEK,MAAM,qBAA1BP,OAAA,CAA4BQ,KAAK;cACzCC,GAAG,EAAG3B,MAAM,CAA4B4B;YAC1C,CAAC;YACDhB,GAAG,EAAE;cACHY,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;MACNhB,SAAS,CAACgB,EAAE,GAAGA,EAAE;IACnB;IAEA,OAAOhB,SAAS;EAClB,CACF,CAAC;;EAED;EACA,OAAO,IAAIV,cAAc,CAACsC,UAAU,EAAE;IACpC,GAAGnB,gBAAgB;IACnBC,OAAO,EAAE;MAAE,IAAIA,OAAO,IAAK,CAAC,CAA6B;IAAE,CAAC;IAC5D;IACAmD,QAAQ,EAAE,IAAIC,OAAO,CAAEC,OAAO,IAAKlE,OAAO,CAACJ,MAAM,CAACsE,OAAO,CAAC;EAC5D,CAAC,CAAC;AACJ;AAEA,SAASvD,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["AnimationGroup","getElement","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","querySelector","keyframeEffect","KeyframeEffect","updateTiming","timing","setKeyframes","keyframes","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 { AnimationGroup } from '../AnimationGroup';\nimport {\n getElement,\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\n ? element?.querySelector(`[data-motion-part~=\"${part}\"]`) // maybe add ~ here as well\n : 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 animation: Animation =\n isViewProgress && timeline\n ? new Animation(keyframeEffect, timeline as AnimationTimeline)\n : new Animation(keyframeEffect);\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,cAAc,QAAQ,mBAAmB;AAClD,SACEC,UAAU,EACVC,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,M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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,IAAIV,cAAc,CAACyC,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":[]}
@@ -120,7 +120,10 @@ function getScrubScene(target, animationOptions, trigger, sceneOptions) {
120
120
  }
121
121
  };
122
122
  }
123
- function getAnimation(target, animationOptions, trigger) {
123
+ function getAnimation(target, animationOptions, trigger, reducedMotion) {
124
+ if (reducedMotion === void 0) {
125
+ reducedMotion = false;
126
+ }
124
127
  const animation = getElementCSSAnimation(target, animationOptions);
125
128
  if (animation) {
126
129
  animation.ready = new Promise(resolve => {
@@ -128,7 +131,9 @@ function getAnimation(target, animationOptions, trigger) {
128
131
  });
129
132
  return animation;
130
133
  }
131
- return getWebAnimation(target, animationOptions, trigger);
134
+ return getWebAnimation(target, animationOptions, trigger, {
135
+ reducedMotion
136
+ });
132
137
  }
133
138
  export { getCSSAnimation, getWebAnimation, getElementCSSAnimation, getElementAnimation, getScrubScene, prepareAnimation, getAnimation, getEasing };
134
139
  //# sourceMappingURL=motion.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AnimationGroup","getEasing","getJsEasing","getWebAnimation","getCSSAnimation","prepareAnimation","getElement","getNamedEffect","getElementCSSAnimation","target","animationOptions","namedEffect","style","effectId","getElementAnimation","effectNames","getNames","element","animations","getAnimations","animationNames","map","anim","animationName","filteredAnimations","forEach","name","includes","push","find","length","filter","id","startsWith","getScrubScene","trigger","sceneOptions","disabled","allowActiveEvent","rest","animation","typeSpecificOptions","window","ViewTimeline","viewSource","componentId","ready","partialAnimation","start","end","getProgress","effect","__","p","activeDuration","getComputedTiming","delay","getTiming","currentTime","destroy","cancel","centeredToTarget","transitionDuration","transitionEasing","customEffect","v","active","progress","getAnimation","Promise","resolve"],"sources":["../../src/motion.ts"],"sourcesContent":["import type {\n AnimationOptions,\n ScrubAnimationOptions,\n TriggerVariant,\n MouseAnimationInstance,\n AnimationEffectAPI,\n CustomMouseAnimationInstance,\n ScrubScrollScene,\n ScrubPointerScene,\n} from './types';\nimport { AnimationGroup } from './AnimationGroup';\nimport { getEasing, getJsEasing } from './utils';\nimport { getWebAnimation } from './api/webAnimations';\nimport { getCSSAnimation } from './api/cssAnimations';\nimport { prepareAnimation } from './api/prepare';\nimport { getElement, getNamedEffect } from './api/common';\n\nfunction getElementCSSAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n): AnimationGroup | null {\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n if (!namedEffect) {\n return null;\n }\n\n if (!namedEffect.style) {\n // if this named effect does not have a style method, attempt to get group of Web Animations\n if (animationOptions.effectId && target) {\n return getElementAnimation(target, animationOptions.effectId);\n }\n\n return null;\n }\n\n const effectNames = namedEffect.getNames(animationOptions);\n const element = typeof target === 'string' ? getElement(target) : target;\n const animations = element?.getAnimations();\n const animationNames =\n animations?.map((anim) => (anim as CSSAnimation).animationName) ||\n ([] as string[]);\n const filteredAnimations: CSSAnimation[] = [];\n\n effectNames.forEach((name) => {\n if (animationNames.includes(name)) {\n filteredAnimations.push(\n animations?.find(\n (anim) => (anim as CSSAnimation).animationName === name,\n ) as CSSAnimation,\n );\n }\n });\n\n return filteredAnimations?.length\n ? new AnimationGroup(filteredAnimations)\n : null;\n}\n\nfunction getElementAnimation(\n target: HTMLElement | string,\n effectId: string,\n): AnimationGroup | null {\n const element = typeof target === 'string' ? getElement(target) : target;\n // somehow get the right animations\n const animations = element\n ?.getAnimations()\n .filter((anim: Animation | CSSAnimation) => {\n const id = anim.id || (anim as CSSAnimation).animationName;\n // if no id/name just return all animations\n return id ? id.startsWith(effectId) : true;\n });\n\n return animations?.length ? new AnimationGroup(animations) : null;\n}\n\nfunction getScrubScene(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger: Partial<TriggerVariant> & { element?: HTMLElement },\n sceneOptions: Record<string, any> = {},\n): ScrubScrollScene[] | ScrubPointerScene {\n const { disabled, allowActiveEvent, ...rest } = sceneOptions;\n const animation = getWebAnimation(target, animationOptions, trigger, rest);\n\n let typeSpecificOptions = {} as Record<string, any>;\n\n if (trigger.trigger === 'view-progress' && !window.ViewTimeline) {\n // TODO(ameerf): consider doing this only for bgscrub to not affect the other scroll effects\n const viewSource = trigger.element || getElement(trigger.componentId!);\n const { ready } = animation as AnimationGroup;\n\n return (animation as AnimationGroup).animations.map((partialAnimation) => {\n return {\n /* we use getters for start and end in order to access the animation's start and end\n only when initializing the scrub scene rather than immediately */\n get start() {\n return partialAnimation.start;\n },\n get end() {\n return partialAnimation.end;\n },\n viewSource,\n ready,\n getProgress() {\n return (animation as AnimationGroup).getProgress();\n },\n effect(__: any, p: number) {\n const { activeDuration } =\n partialAnimation.effect!.getComputedTiming();\n const { delay } = partialAnimation.effect!.getTiming();\n\n partialAnimation.currentTime =\n ((delay || 0) + ((activeDuration as number) || 0)) * p;\n },\n disabled,\n destroy() {\n partialAnimation.cancel();\n },\n } as ScrubScrollScene;\n });\n } else if (trigger.trigger === 'pointer-move') {\n const { centeredToTarget, transitionDuration, transitionEasing } =\n animationOptions as ScrubAnimationOptions;\n\n typeSpecificOptions = {\n target: (animation as MouseAnimationInstance).target,\n centeredToTarget,\n allowActiveEvent,\n };\n\n if (animationOptions.customEffect && transitionDuration) {\n typeSpecificOptions.transitionDuration = transitionDuration;\n typeSpecificOptions.transitionEasing = getJsEasing(transitionEasing);\n }\n }\n\n return {\n ...typeSpecificOptions,\n getProgress() {\n return (\n animation as AnimationGroup | CustomMouseAnimationInstance\n ).getProgress();\n },\n effect(\n __: any,\n p: number | { x: number; y: number },\n v?: { x: number; y: number },\n active?: boolean,\n ) {\n animation.progress(\n v\n ? {\n // @ts-expect-error spread error on p\n ...p,\n v,\n active,\n }\n : p,\n );\n },\n disabled,\n destroy() {\n animation.cancel();\n },\n } as ScrubPointerScene;\n}\n\nfunction getAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n): AnimationGroup | MouseAnimationInstance | null {\n const animation = getElementCSSAnimation(target, animationOptions);\n\n if (animation) {\n animation.ready = new Promise((resolve) => {\n prepareAnimation(target, animationOptions, resolve);\n });\n\n return animation;\n }\n\n return getWebAnimation(\n target,\n animationOptions,\n trigger,\n );\n}\n\nexport {\n getCSSAnimation,\n getWebAnimation,\n getElementCSSAnimation,\n getElementAnimation,\n getScrubScene,\n prepareAnimation,\n getAnimation,\n getEasing,\n};\n\nexport type { AnimationGroup };\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,SAAS;AAChD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,UAAU,EAAEC,cAAc,QAAQ,cAAc;AAEzD,SAASC,sBAAsBA,CAC7BC,MAAmC,EACnCC,gBAAkC,EACX;EACvB,MAAMC,WAAW,GAAGJ,cAAc,CAChCG,gBACF,CAAmC;EAEnC,IAAI,CAACC,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,IAA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G;MACRnB,SAAS,CAACoB,MAAM,CAAC,CAAC;IACpB;EACF,CAAC;AACH;AAEA,SAASQ,YAAYA,CACnB3D,MAAmC,EACnCC,gBAAkC,EAClCyB,OAA6D,EACb;EAChD,MAAMK,SAAS,GAAGhC,sBAAsB,CAACC,MAAM,EAAEC,gBAAgB,CAAC;EAElE,IAAI8B,SAAS,EAAE;IACbA,SAAS,CAACM,KAAK,GAAG,IAAIuB,OAAO,CAAEC,OAAO,IAAK;MACzCjE,gBAAgB,CAACI,MAAM,EAAEC,gBAAgB,EAAE4D,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO9B,SAAS;EAClB;EAEA,OAAOrC,eAAe,CACpBM,MAAM,EACNC,gBAAgB,EAChByB,OACF,CAAC;AACH;AAEA,SACE/B,eAAe,EACfD,eAAe,EACfK,sBAAsB,EACtBM,mBAAmB,EACnBoB,aAAa,EACb7B,gBAAgB,EAChB+D,YAAY,EACZnE,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["AnimationGroup","getEasing","getJsEasing","getWebAnimation","getCSSAnimation","prepareAnimation","getElement","getNamedEffect","getElementCSSAnimation","target","animationOptions","namedEffect","style","effectId","getElementAnimation","effectNames","getNames","element","animations","getAnimations","animationNames","map","anim","animationName","filteredAnimations","forEach","name","includes","push","find","length","filter","id","startsWith","getScrubScene","trigger","sceneOptions","disabled","allowActiveEvent","rest","animation","typeSpecificOptions","window","ViewTimeline","viewSource","componentId","ready","partialAnimation","start","end","getProgress","effect","__","p","activeDuration","getComputedTiming","delay","getTiming","currentTime","destroy","cancel","centeredToTarget","transitionDuration","transitionEasing","customEffect","v","active","progress","getAnimation","reducedMotion","Promise","resolve"],"sources":["../../src/motion.ts"],"sourcesContent":["import type {\n AnimationOptions,\n ScrubAnimationOptions,\n TriggerVariant,\n MouseAnimationInstance,\n AnimationEffectAPI,\n CustomMouseAnimationInstance,\n ScrubScrollScene,\n ScrubPointerScene,\n} from './types';\nimport { AnimationGroup } from './AnimationGroup';\nimport { getEasing, getJsEasing } from './utils';\nimport { getWebAnimation } from './api/webAnimations';\nimport { getCSSAnimation } from './api/cssAnimations';\nimport { prepareAnimation } from './api/prepare';\nimport { getElement, getNamedEffect } from './api/common';\n\nfunction getElementCSSAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n): AnimationGroup | null {\n const namedEffect = getNamedEffect(\n animationOptions,\n ) as AnimationEffectAPI<any> | null;\n\n if (!namedEffect) {\n return null;\n }\n\n if (!namedEffect.style) {\n // if this named effect does not have a style method, attempt to get group of Web Animations\n if (animationOptions.effectId && target) {\n return getElementAnimation(target, animationOptions.effectId);\n }\n\n return null;\n }\n\n const effectNames = namedEffect.getNames(animationOptions);\n const element = typeof target === 'string' ? getElement(target) : target;\n const animations = element?.getAnimations();\n const animationNames =\n animations?.map((anim) => (anim as CSSAnimation).animationName) ||\n ([] as string[]);\n const filteredAnimations: CSSAnimation[] = [];\n\n effectNames.forEach((name) => {\n if (animationNames.includes(name)) {\n filteredAnimations.push(\n animations?.find(\n (anim) => (anim as CSSAnimation).animationName === name,\n ) as CSSAnimation,\n );\n }\n });\n\n return filteredAnimations?.length\n ? new AnimationGroup(filteredAnimations)\n : null;\n}\n\nfunction getElementAnimation(\n target: HTMLElement | string,\n effectId: string,\n): AnimationGroup | null {\n const element = typeof target === 'string' ? getElement(target) : target;\n // somehow get the right animations\n const animations = element\n ?.getAnimations()\n .filter((anim: Animation | CSSAnimation) => {\n const id = anim.id || (anim as CSSAnimation).animationName;\n // if no id/name just return all animations\n return id ? id.startsWith(effectId) : true;\n });\n\n return animations?.length ? new AnimationGroup(animations) : null;\n}\n\nfunction getScrubScene(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger: Partial<TriggerVariant> & { element?: HTMLElement },\n sceneOptions: Record<string, any> = {},\n): ScrubScrollScene[] | ScrubPointerScene {\n const { disabled, allowActiveEvent, ...rest } = sceneOptions;\n const animation = getWebAnimation(target, animationOptions, trigger, rest);\n\n let typeSpecificOptions = {} as Record<string, any>;\n\n if (trigger.trigger === 'view-progress' && !window.ViewTimeline) {\n // TODO(ameerf): consider doing this only for bgscrub to not affect the other scroll effects\n const viewSource = trigger.element || getElement(trigger.componentId!);\n const { ready } = animation as AnimationGroup;\n\n return (animation as AnimationGroup).animations.map((partialAnimation) => {\n return {\n /* we use getters for start and end in order to access the animation's start and end\n only when initializing the scrub scene rather than immediately */\n get start() {\n return partialAnimation.start;\n },\n get end() {\n return partialAnimation.end;\n },\n viewSource,\n ready,\n getProgress() {\n return (animation as AnimationGroup).getProgress();\n },\n effect(__: any, p: number) {\n const { activeDuration } =\n partialAnimation.effect!.getComputedTiming();\n const { delay } = partialAnimation.effect!.getTiming();\n\n partialAnimation.currentTime =\n ((delay || 0) + ((activeDuration as number) || 0)) * p;\n },\n disabled,\n destroy() {\n partialAnimation.cancel();\n },\n } as ScrubScrollScene;\n });\n } else if (trigger.trigger === 'pointer-move') {\n const { centeredToTarget, transitionDuration, transitionEasing } =\n animationOptions as ScrubAnimationOptions;\n\n typeSpecificOptions = {\n target: (animation as MouseAnimationInstance).target,\n centeredToTarget,\n allowActiveEvent,\n };\n\n if (animationOptions.customEffect && transitionDuration) {\n typeSpecificOptions.transitionDuration = transitionDuration;\n typeSpecificOptions.transitionEasing = getJsEasing(transitionEasing);\n }\n }\n\n return {\n ...typeSpecificOptions,\n getProgress() {\n return (\n animation as AnimationGroup | CustomMouseAnimationInstance\n ).getProgress();\n },\n effect(\n __: any,\n p: number | { x: number; y: number },\n v?: { x: number; y: number },\n active?: boolean,\n ) {\n animation.progress(\n v\n ? {\n // @ts-expect-error spread error on p\n ...p,\n v,\n active,\n }\n : p,\n );\n },\n disabled,\n destroy() {\n animation.cancel();\n },\n } as ScrubPointerScene;\n}\n\nfunction getAnimation(\n target: HTMLElement | string | null,\n animationOptions: AnimationOptions,\n trigger?: Partial<TriggerVariant> & { element?: HTMLElement },\n reducedMotion: boolean = false,\n): AnimationGroup | MouseAnimationInstance | null {\n const animation = getElementCSSAnimation(target, animationOptions);\n\n if (animation) {\n animation.ready = new Promise((resolve) => {\n prepareAnimation(target, animationOptions, resolve);\n });\n\n return animation;\n }\n\n return getWebAnimation(target, animationOptions, trigger, { reducedMotion });\n}\n\nexport {\n getCSSAnimation,\n getWebAnimation,\n getElementCSSAnimation,\n getElementAnimation,\n getScrubScene,\n prepareAnimation,\n getAnimation,\n getEasing,\n};\n\nexport type { AnimationGroup };\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,SAAS;AAChD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,UAAU,EAAEC,cAAc,QAAQ,cAAc;AAEzD,SAASC,sBAAsBA,CAC7BC,MAAmC,EACnCC,gBAAkC,EACX;EACvB,MAAMC,WAAW,GAAGJ,cAAc,CAChCG,gBACF,CAAmC;EAEnC,IAAI,CAACC,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,IAAI,CAACA,WAAW,CAACC,KAAK,EAAE;IACtB;IACA,IAAIF,gBAAgB,CAACG,QAAQ,IAAIJ,MAAM,EAAE;MACvC,OAAOK,mBAAmB,CAACL,MAAM,EAAEC,gBAAgB,CAACG,QAAQ,CAAC;IAC/D;IAEA,OAAO,IAAI;EACb;EAEA,MAAME,WAAW,GAAGJ,WAAW,CAACK,QAAQ,CAACN,gBAAgB,CAAC;EAC1D,MAAMO,OAAO,GAAG,OAAOR,MAAM,KAAK,QAAQ,GAAGH,UAAU,CAACG,MAAM,CAAC,GAAGA,MAAM;EACxE,MAAMS,UAAU,GAAGD,OAAO,oBAAPA,OAAO,CAAEE,aAAa,CAAC,CAAC;EAC3C,MAAMC,cAAc,GAClB,CAAAF,UAAU,oBAAVA,UAAU,CAAEG,GAAG,CAAEC,IAAI,IAAMA,IAAI,CAAkBC,aAAa,CAAC,KAC9D,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AAEkC;EAAc,CAAC,CAAC;AAC9E;AAEA,SACEjE,eAAe,EACfD,eAAe,EACfK,sBAAsB,EACtBM,mBAAmB,EACnBoB,aAAa,EACb7B,gBAAgB,EAChB+D,YAAY,EACZnE,SAAS","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"webAnimations.d.ts","sourceRoot":"","sources":["../../../src/api/webAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,gBAAgB,EAEhB,sBAAsB,EAEtB,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAoCnD,iBAAS,eAAe,CACtB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,EAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,aAAa,CAAC,EAAE,QAAQ,GACvB,cAAc,GAAG,sBAAsB,CAuIzC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"webAnimations.d.ts","sourceRoot":"","sources":["../../../src/api/webAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,gBAAgB,EAEhB,sBAAsB,EAEtB,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4CnD,iBAAS,eAAe,CACtB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,EAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,aAAa,CAAC,EAAE,QAAQ,GACvB,cAAc,GAAG,sBAAsB,CAuIzC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -11,7 +11,7 @@ declare function getScrubScene(target: HTMLElement | string | null, animationOpt
11
11
  }, sceneOptions?: Record<string, any>): ScrubScrollScene[] | ScrubPointerScene;
12
12
  declare function getAnimation(target: HTMLElement | string | null, animationOptions: AnimationOptions, trigger?: Partial<TriggerVariant> & {
13
13
  element?: HTMLElement;
14
- }): AnimationGroup | MouseAnimationInstance | null;
14
+ }, reducedMotion?: boolean): AnimationGroup | MouseAnimationInstance | null;
15
15
  export { getCSSAnimation, getWebAnimation, getElementCSSAnimation, getElementAnimation, getScrubScene, prepareAnimation, getAnimation, getEasing, };
16
16
  export type { AnimationGroup };
17
17
  //# sourceMappingURL=motion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,cAAc,EACd,sBAAsB,EAGtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAe,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,iBAAS,sBAAsB,CAC7B,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,gBAAgB,GACjC,cAAc,GAAG,IAAI,CAuCvB;AAED,iBAAS,mBAAmB,CAC1B,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,QAAQ,EAAE,MAAM,GACf,cAAc,GAAG,IAAI,CAYvB;AAED,iBAAS,aAAa,CACpB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AS,mBAAmB,CAC1B,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,QAAQ,EAAE,MAAM,GACf,cAAc,GAAG,IAAI,CAYvB;AAED,iBAAS,aAAa,CACpB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,EAC5D,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GACrC,gBAAgB,EAAE,GAAG,iBAAiB,CAqFxC;AAED,iBAAS,YAAY,CACnB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,EAC7D,aAAa,GAAE,OAAe,GAC7B,cAAc,GAAG,sBAAsB,GAAG,IAAI,CAYhD;AAED,OAAO,EACL,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/motion",
3
- "version": "1.604.0",
3
+ "version": "1.605.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "wow!Team",
@@ -83,5 +83,5 @@
83
83
  "wallaby": {
84
84
  "autoDetect": true
85
85
  },
86
- "falconPackageHash": "ee3298727e5bb0634ddc093e000d5d6e9afdf839369a2f87a12dcec8"
86
+ "falconPackageHash": "23d7da993f799a3042a6c1835fd2c43965aba577a86d728c47c7b404"
87
87
  }