Skip to content

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

@BlackRam-oss

Description

@BlackRam-oss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions