Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var player = GetPlayer();
- player.SetVar("swipeRight",false);
- var xDown = null;
- var yDown = null;
- document.addEventListener('touchstart', function(event) {
- xDown = event.touches[0].clientX;
- yDown = event.touches[0].clientY;
- }, false);
- document.addEventListener('touchmove', function(event) {
- if (!xDown || !yDown) {
- return;
- }
- var xDiff = xDown - event.touches[0].clientX;
- var yDiff = yDown - event.touches[0].clientY;
- if (Math.abs(xDiff) > Math.abs(yDiff)) {
- if (xDiff < 0) {
- // swipe right detected
- // do something here
- player.SetVar("swipeRight",true);
- player.SetVar("swipeRight",false);
- }
- xDown = null;
- yDown = null;
- }
- }, false);
- document.addEventListener('touchend', function(event) {
- xDown = null;
- yDown = null;
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement