motion icon indicating copy to clipboard operation
motion copied to clipboard

[BUG] After AnimationPlaybackControlsWithThen.stop(), an update is executed

Open BlackRam-oss opened this issue 8 months ago • 0 comments

2. Describe the bug

After animating an element with "animate," I noticed that using the stop() function changes the component again after executing stop(). I think this is wrong, also because stop is not asynchronous.

the problem is that there is no way to understand when the animation is actually stopped (same thing goes for complete() )

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/t254cq

You can test this with the following code:

import { animate } from "motion";

let proxy = new Proxy(
    { rotation: 0 },
    {
        set: (target, p, newValue) => {
            console.log("edit");
            if (p === "rotation") {
                target[p] = newValue;
            }
            return true;
        },
    }
);
const a = animate(
    proxy,
    {
        rotation: 1,
    },
    { duration: 10, repeat: Infinity, repeatType: "loop", ease: "linear" }
);
// new timeout
setTimeout(() => {
    a.stop();
    console.log("stop");
}, 100);
return a;

4. Steps to reproduce

Steps to reproduce the behavior:

  • Click the button
  • See the console

5. Expected behavior

after stop there should be no other logs

BlackRam-oss avatar Jul 28 '25 14:07 BlackRam-oss