zoukankan      html  css  js  c++  java
  • 手机下的ev.pageX无效

     
    把  ev.pageX  换成  e.originalEvent.targetTouches[0].pageX;
     
    例子:
    var start_x, start_y, end_x, end_y, move_num;
        var client_height = $(window).height();
     
        $("#containner div").on("touchstart"function(e) {
            start_x = e.originalEvent.targetTouches[0].clientX;
            start_y = e.originalEvent.targetTouches[0].clientY;
            console.log(start_x);
            console.log(start_y);
     
        });
        $("#containner div").on("touchmove"function(e) {
            $(this).removeClass("slow_action");
            end_x = e.originalEvent.targetTouches[0].clientX;
            end_y = e.originalEvent.targetTouches[0].clientY;
            move_num = (end_y - start_y).toFixed(2);
            console.log(move_num);
            var tf_num = "translateY(" + move_num + "px)";
            $(this).css("-webkit-transform", tf_num);
     
        });
        $("#containner div").on("touchend"function() {
            $(this).addClass("slow_action");
            if (move_num < -(client_height / 2)) {
     
                $(this).css({
                    "-webkit-transform""translateY(-900px)",
     
                });
     
            else if (move_num > 0) {
                $(this).css({
                    "-webkit-transform""translateY(0px)",
     
                });
            else {
                $(this).css({
                    "-webkit-transform""translateY(0px)",
     
                });
     
            }
     
     
     
     
        });
  • 相关阅读:
    Python3.5.2官方文档学习备忘录
    Linux下升级python版本
    役物,役于物
    各种编辑器添加注释快捷键
    Python3爬取百度百科(配合PHP)
    Python3向网页POST数据
    Python3爬取中文网址
    Python3批量爬取网页图片
    django中间件
    django创建上下文
  • 原文地址:https://www.cnblogs.com/zhengyan/p/5045399.html
Copyright © 2011-2022 走看看