peanut
peanut

Reputation: 283

Return mouse position at a given time

I want to set the position of something relative to the current position of the mouse.

Is there a way that I can get the current position of the mouse without needing to constantly track where it is?

Ideally can I use the window property to find it?

Upvotes: 0

Views: 44

Answers (1)

ponmuthuselvam
ponmuthuselvam

Reputation: 36

Any way to track mouse position you have to use an event listener. if you have to do some different actions while tracking continuously would create issues like freezing.

To avoid these kinds of issues, we have two techniques

  1. Event debouncing (listen based on a particular interval condition)
  2. Event Throttling (to control the rate of listening)

check out this link https://codeburst.io/throttling-and-debouncing-in-javascript-b01cad5c8edf

Upvotes: 1

Related Questions