Search code examples
javascriptjquerymouseswipe

Simulate swipe with mouse in javascript


I'm trying to make an image rotator that works on mobile devices using swipe for navigation. I'm also trying to make the same rotator to work on PC browsers but to be able to use the mouse drag to simulate swipe. Any good ideeas?


Solution

  • You'll want to handle onmousedown, onmousemove, and onmouseup events, keeping track of the mouse position and manipulating your image rotator accordingly.