Friends, I need to make a banner on which some objects move at the mousemove event. The whole point is that the customer requires that, after the cursor is stopped, the objects stop by inertia. I do not understand how to implement this. The only thought was to use the function with an interval of 1ms and check dx / dy in it. Tell me something who can. JQuery plugins are not desirable. I would like to understand the mechanics myself. Thanks in advance.

  • There seems to be good decisions. Especially all the same, in theory, we need a SetInterval, since for the inertia you need to understand not only the direction, but also the speed of the mouse movement. - MedvedevDev
  • It is possible in terms of RxJS. At the input, you submit the stream of events "the mouse has moved", filter this stream according to the geometrical coordinates, apply the debounce operator to it with the required delay and at the output generate the event "the mouse has stopped." - iTollu

0