juliangarnier / anime

JavaScript animation engine
https://animejs.com
MIT License
50.42k stars 3.68k forks source link

Duration property problem when I use an event #881

Open rod203 opened 10 months ago

rod203 commented 10 months ago

I'm creating a pointer click animation using mouseDown and mouseUp event and when the animation has duration (any value except 0) the animation doesn't work. When I put the duration on 0 the element scale but with out animation.

Here is the code

const toggleDown = () => {
  anime.remove(cursorInner);
  anime({
    targets: cursorInner,
    duration: 1000,
    scale: 2,
    easing: "easeInOutSine",
  });
};
const toggleUp = () => {
  anime.remove(cursorInner);
  anime({
    targets: cursorInner,
    duration: 1000,
    scale: 1,
    easing: "easeInOutSine",
  });
};

document.addEventListener("mousedown", toggleDown);
document.addEventListener("mouseup", toggleUp);