import { Feature } from "../feature.mjs"; import { isHidden } from "../../utils/is-hidden.mjs"; import { createAnimationState, isAnimationControls } from "motion-dom"; //#region src/features/animation/animation.ts var AnimationFeature = class extends Feature { static { this.key = "animation"; } constructor(state) { super(state); const ve = state.visualElement; ve.animationState ||= createAnimationState(ve); } updateAnimationControlsSubscription() { const { animate } = this.state.options; if (isAnimationControls(animate)) this.unmountControls = animate.subscribe(this.state.visualElement); } /** * Subscribe any provided AnimationControls to the component's VisualElement */ mount() { if (!!isHidden(this.state.element)) this.state.setActive("exit", true); else this.state.visualElement.animationState?.animateChanges(); this.updateAnimationControlsSubscription(); } update() { this.state.visualElement.animationState?.animateChanges(); const { animate } = this.state.visualElement.getProps(); const { animate: prevAnimate } = this.state.visualElement.prevProps || {}; if (animate !== prevAnimate) this.updateAnimationControlsSubscription(); } unmount() { this.state.visualElement.animationState.reset(); this.unmountControls?.(); } }; //#endregion export { AnimationFeature };