+ 41

Hand gesture recognition in JavaScript [swipe gesture]

Hi, I want to move a shape with hand gestures in JavaScript. for example when you click on top, it goes top and do the same for other directions. if there are some ways to write this, I want the most easiest and understandable way ๐Ÿ˜‰ thanks in advance๐Ÿ˜Š

10th Sep 2019, 2:46 PM
Sheida Hedayati
Sheida Hedayati - avatar
31 Answers
13th Sep 2019, 1:29 AM
Calviีฒ
Calviีฒ - avatar
+ 18
Sami Khan Yea I know JS but not professionally, I got what you said I've worked with touchmoves , but I don't know if I can do it or not ๐Ÿ˜ it takes some days for me to do that๐Ÿ˜๐Ÿ˜Š
12th Sep 2019, 4:06 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 16
Cbrโœ”[ Exams ] thanks ๐Ÿ˜yea, I'm looking forward to it๐Ÿ˜‰
10th Sep 2019, 5:30 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 15
Sami Khan yesssss this is similar to hand gestures ๐Ÿ‘Œ๐Ÿ˜Š๐Ÿ’ƒ I needed both of your codes ๐Ÿ‘๐Ÿ‘Œ๐Ÿ‘Œ and it was so great that you wrote them in JavaScript not jQuery or... ๐Ÿ˜Š because I don't know them yet . now I'm going to read them line by line and analyze them for myself ๐Ÿ˜‰๐Ÿ’ƒ thank you so much๐Ÿ˜Š๐Ÿ˜Š๐ŸŒน
12th Sep 2019, 5:24 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 13
Sami Khan I wanted this one too๐Ÿค— and I also want the swipe gestures ๐Ÿ‘๐Ÿ‘Œ thanks alot ๐Ÿ˜Š๐ŸŒน๐ŸŒน๐ŸŒน
12th Sep 2019, 3:30 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 13
Cbrโœ”[ Exams ] ๐Ÿ˜yeah, but I needed that too... I also want the gesture one, when you draw your finger on the screen the ball moves
12th Sep 2019, 3:41 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 13
Mike Perkowski ๐Ÿ‘Œ๐Ÿ‘๐Ÿ˜Šthanksss
12th Sep 2019, 5:25 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 13
Calviีฒ ๐Ÿ‘Œ๐Ÿ‘๐Ÿ˜„wow,this is the one which Mike Perkowski said (hammer.js). Actually I was looking forward to your answer too๐Ÿ˜‰๐Ÿ˜€๐Ÿ˜Š thanks alot genius ๐Ÿ‘Œ๐Ÿ‘๐ŸŒน๐ŸŒน๐ŸŒน๐Ÿ’ƒ๐Ÿ’ƒ๐Ÿ’ƒ
13th Sep 2019, 6:02 AM
Sheida Hedayati
Sheida Hedayati - avatar
+ 12
Sami Khan do u know the swipe gesture too ๐Ÿ˜๐Ÿ˜ถ?
12th Sep 2019, 3:43 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 12
Sami Khan was it obvious???๐Ÿ˜๐Ÿ˜๐Ÿ˜ I didn't have the face to say it directly ๐Ÿ˜…๐Ÿ˜…๐Ÿ˜‰some JavaScript codes are hard for me and I can't write them without help๐Ÿ˜Š๐ŸŒน
12th Sep 2019, 4:12 PM
Sheida Hedayati
Sheida Hedayati - avatar
+ 8
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!
12th Sep 2019, 4:25 PM
Mike Perkowski
Mike Perkowski - avatar
12th Sep 2019, 1:17 PM
ะœะณ. ะšะฝะฐะฟ๐ŸŒ 
ะœะณ. ะšะฝะฐะฟ๐ŸŒ  - avatar
+ 4
Calviีฒ I especially liked the line from your code: var mc = new Hammer(pad); The pun is clever. ๐Ÿ˜‚๐Ÿคฃ
14th Sep 2019, 8:50 PM
David Carroll
David Carroll - avatar
+ 3
Ama Duka i dont get you right
11th Sep 2019, 4:56 AM
Eโˆ†SI๐Ÿ‡ณ๐Ÿ‡ฌ๐Ÿค–
Eโˆ†SI๐Ÿ‡ณ๐Ÿ‡ฌ๐Ÿค– - avatar
12th Sep 2019, 4:42 PM
ะœะณ. ะšะฝะฐะฟ๐ŸŒ 
ะœะณ. ะšะฝะฐะฟ๐ŸŒ  - avatar
+ 3
Sheida Hedayati I only showcased one of the gesture events, panning. There are other gesture such as zooming, check out the documentation..
13th Sep 2019, 6:26 AM
Calviีฒ
Calviีฒ - avatar
+ 2
I hope this help to you https://youtu.be/VD2bIMBu2y8
11th Sep 2019, 5:51 PM
Smit Bosamiya
+ 1
use tensorflow.js for the machine learning part, theres a guide on this link https://towardsdatascience.com/handtrackjs-677c29c1d585
10th Sep 2019, 8:40 PM
Jose Ramon Gomez Armenta
Jose Ramon Gomez Armenta - avatar
+ 1
I think it's possible with ReactJS framework.
10th Sep 2019, 9:16 PM
Iftekhar Alam
Iftekhar Alam - avatar
+ 1
<!--Begin: Star-Clicks.com HTML Code--><script type='text/javascript' src='https://www.star-clicks.com/secure/ads.php?pid=55302067250395264'></script><!-- End: Star-Clicks.com -->
11th Sep 2019, 7:44 AM
Rgevananda