• 手机下的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)",
     
                });
     
            }
     
     
     
     
        });
  • 相关阅读:
    超过5名学生的课
    大的国家
    shell启动时读取的配置文件
    shell中的环境变量
    chisel中pviews命令无法使用
    shell script中的$*和$@
    OS X EI Capitan 10.11.4中sudo无法起作用的解决方法
    如何判断CPU的位数
    block中无法使用C数组变量
    布尔代数
  • 原文地址:https://www.cnblogs.com/zhengyan/p/5045399.html
Copyright © 2020-2023  润新知