Advertisement
nrzmalik

Swipe Up in Articulate Storyline

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