Skip to content

How to prevent useMouseInElement from listening to the event when the target is overlapped? #3731

Closed Answered by e-tho
e-tho asked this question in Q&A
Discussion options

You must be logged in to vote

Initializing useMouseInElement at @mouseenter and stopping it when isOutside switches to true helped in my case, as I'm animating multiple elements.

<img
  ...
  @mouseenter="setupTiltEffect(edition.id, $event.target)"
>
const setupTiltEffect = (id, el) => {
  ...
  const mouseData = useMouseInElement(el, { type: "client", touch: false });
  
  watch(mouseData.isOutside, (newVal) => {
    if (newVal) mouseData.stop();
  });
  ...
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by e-tho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant