Skip to content

Commit

Permalink
Ensuring instant animations return animation controls (#2687)
Browse files Browse the repository at this point in the history
* Updating

* Returning controls
  • Loading branch information
mattgperry authored May 29, 2024
1 parent 9f47af2 commit 2d68524
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/framer-motion/src/animation/GroupPlaybackControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ export class GroupPlaybackControls implements AnimationPlaybackControls {
this.runAll("pause")
}

stop() {
this.runAll("stop")
}
// Bound to accomodate common `return animation.stop` pattern
stop = () => this.runAll("stop")

cancel() {
this.runAll("cancel")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { secondsToMilliseconds } from "../../utils/time-conversion"
import type { MotionValue, StartAnimation } from "../../value"
import { getDefaultTransition } from "../utils/default-transitions"
import { getValueTransition, isTransitionDefined } from "../utils/transitions"
import { ValueAnimationOptions } from "../types"
import { AnimationPlaybackControls, ValueAnimationOptions } from "../types"
import type { UnresolvedKeyframes } from "../../render/utils/KeyframesResolver"
import { MotionGlobalConfig } from "../../utils/GlobalConfig"
import { instantAnimationState } from "../../utils/use-instant-transition-state"
Expand All @@ -12,6 +12,7 @@ import { getFinalKeyframe } from "../animators/waapi/utils/get-final-keyframe"
import { frame } from "../../frameloop/frame"
import { AcceleratedAnimation } from "../animators/AcceleratedAnimation"
import { MainThreadAnimation } from "../animators/MainThreadAnimation"
import { GroupPlaybackControls } from "../GroupPlaybackControls"

export const animateMotionValue =
<V extends string | number>(
Expand All @@ -22,7 +23,7 @@ export const animateMotionValue =
element?: VisualElement<any>,
isHandoff?: boolean
): StartAnimation =>
(onComplete) => {
(onComplete): AnimationPlaybackControls => {
const valueTransition = getValueTransition(transition, name) || {}

/**
Expand Down Expand Up @@ -124,7 +125,9 @@ export const animateMotionValue =
options.onComplete!()
})

return
// We still want to return some animation controls here rather
// than returning undefined
return new GroupPlaybackControls([])
}
}

Expand Down

0 comments on commit 2d68524

Please sign in to comment.