Advertisement
nrzmalik

Swipe Down in Articulate Storyline

Mar 2nd, 2023 (edited)
312
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 xDown = null;
  2. var yDown = null;
  3. var player = GetPlayer();
  4. player.SetVar("swipeDown",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 down detected
  22.       // do something here
  23.          
  24.         player.SetVar("swipeDown",true);
  25.          player.SetVar("swipeDown",false);
  26.      
  27.     }
  28.     xDown = null;
  29.     yDown = null;
  30.   }
  31. }, false);
  32.  
  33. document.addEventListener('touchend', function(event) {
  34.   xDown = null;
  35.   yDown = null;
  36. }, false);
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement