Advertisement
nrzmalik

Swipe Right in Articulate Storyline

Mar 2nd, 2023 (edited)
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.83 KB | Source Code | 0 0
  1. var player = GetPlayer();
  2. player.SetVar("swipeRight",false);
  3. var xDown = null;
  4. var yDown = null;
  5.  
  6. document.addEventListener('touchstart', function(event) {
  7.   xDown = event.touches[0].clientX;
  8.   yDown = event.touches[0].clientY;
  9. }, false);
  10.  
  11. document.addEventListener('touchmove', function(event) {
  12.   if (!xDown || !yDown) {
  13.     return;
  14.   }
  15.  
  16.   var xDiff = xDown - event.touches[0].clientX;
  17.   var yDiff = yDown - event.touches[0].clientY;
  18.  
  19.   if (Math.abs(xDiff) > Math.abs(yDiff)) {
  20.     if (xDiff < 0) {
  21.      
  22.       // swipe right detected
  23.       // do something here
  24.        
  25.         player.SetVar("swipeRight",true);
  26.          player.SetVar("swipeRight",false);
  27.      
  28.     }
  29.     xDown = null;
  30.     yDown = null;
  31.   }
  32. }, false);
  33.  
  34. document.addEventListener('touchend', function(event) {
  35.   xDown = null;
  36.   yDown = null;
  37. }, false);
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement