Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
0
You can do it with event listeners: for touchscreens, you need touchstart, touchend, and maybe touchmove. You will need a handler function to receive the positions of the touch, something like this: window.addEventListener("touchstart", e => console.log(e.touches[0].clientX)); This simple function tells you the x coordinate of your finger when you touch the screen, and from here you can do more stuff. For the computer, you need mousedown, mouseup and maybe mousemove. It's pretty similar, and kind of boring, but you can look it up on the internet (keywords: js touchstart event, for example) I've made some codes that use swiping, maybe those links can help: https://code.sololearn.com/Wkc93BbiM8Oj/?ref=app https://code.sololearn.com/W30sBq1HXXcd/?ref=app The reason I didn't tell you the exact answer is because 1. finding it for yourself will be more satisfying and helpful and 2. I'm lazy
27th Mar 2020, 6:04 PM
Airree
Airree - avatar