thanks in advance😊
There are libraries for swipe gestures in the browser like hammer.js and you can probably use those, but if I were implementing this from scratch, I’d assign a mousedown and a touchstart event listener to any element I wanted to be “swipable”. In the event listener, I’d save the inital touch or mouse down point as the starting point and then use mouseup and touchend events to get the end point, then handle the logic to determine which direction to swipe by comparing the start and end x and y values.
If you wanted to have something happen depending on if you tocuhed the top, bottom, right or left of the element, you could use the same approach only use the .getBoundingClientRect() method to find the center point of the element and compare that point to the touch point.
I hope this helps! Good luck!