Home > Web Front-end > H5 Tutorial > Implementation of H5 slide-up jump page (code example)

Implementation of H5 slide-up jump page (code example)

青灯夜游
Release: 2018-10-11 17:18:42
forward
4345 people have browsed it

This article will introduce to you the implementation of H5 slide-up jump page. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Method one:

jquery method

movePage($('body'));
   function movePage(dom) {
       var startY, moveY, moveSpave;
       dom.on("touchstart", function(e) {
               startY = e.originalEvent.touches[0].pageY; return startY;
        });
        dom.on("touchmove", function(e) {
              moveY = e.originalEvent.touches[0].pageY;
              moveSpave = startY - moveY;
              if (moveSpave > 15) {
                   location.href = 'main.html';              /* 跳转到main.html */
               }
        });
  }
Copy after login

Method two:

Native method

     var strat,move,num; /*定义三个变量, 记录开始、结束距离顶部的距离*/
     p_demo.addEventListener("touchstart", function (e){        /*触摸开始*/
            console.log("触摸开始")
            // console.log(e)
            start = e.touches[0].pageY;
            console.log(start)       /*得出刚触屏时距离页面顶部的距离*/
      })
     p_demo.addEventListener("touchmove", function (e){       /*触摸移动*/
            console.log("触摸移动")
            // console.log(e)
            move = e.touches[0].pageY;
            console.log(move)     /*得出触屏结束后距离页面顶部的距离*/
    }) 
   p_demo.addEventListener("touchend", function (e){            /*触摸结束*/
            console.log("触摸结束")
            // console.log(e)
            num = start - move ;   /*得出开始和结束距离页面顶部的差值*/
            if(num>15){
                 location.href="main.html"           /* 跳转到main.html */
            }
    })
Copy after login

Summary: The above is the summary of this article All content, I hope it will be helpful to everyone's study. For more related tutorials, please visit Html5 Video Tutorial, jQuery Video Tutorial!

Related recommendations:

php public welfare training video tutorial

HTML5 graphic tutorial

HTML5Online Manual

html5 special effects code collection

The above is the detailed content of Implementation of H5 slide-up jump page (code example). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template