How to change the pages of a mobile site by dragging your finger on the touch screen to the right or left using javascript

Asked

Viewed 22 times

0

I wonder how I can use javascript to perform the page change on the mobile touch screen, so that dragging left go to previous page and right to next page.

Currently I have this code below that uses the arrow keys of the keyboard, I wonder how I can complement this code with this additional function.

<script type="text/javascript">

document.onkeydown = arrowChecker;

function arrowChecker(e) {  
    e = e || window.event;
    if (e.keyCode == "37") { //left
        document.location.href = "/'.$UrlArray1.'/'.$UrlArray2.'/?leitor=fullpg10&paginainicial='.($inicioA).'&paginafinal='.($fimA).'&#iniciopg";
    }
    else if (e.keyCode == "39") { //right
       document.location.href = "/'.$UrlArray1.'/'.$UrlArray2.'/?leitor=fullpg10&paginainicial='.($fim+1).'&paginafinal='.($fim+10).'&#iniciopg";
    }
}
 </script>
  • 1

    that helps? https://answall.com/questions/34149/howto determinar-a-dire%C3%A7%C3%a3o-do-touchmove only adapt to call the functions you already have

  • That’s just what I wanted to thank you for.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.