zoukankan      html  css  js  c++  java
  • [转] zepto的各种坑

    1、编译zepto。模块之前可能有依赖关系,整体顺序参考下面这个即可:

    MODULES="zepto event ajax form ie detect fx fx_methods assets data deferred callbacks selector touch gesture stack ios3" npm run-script dist
    

    2、支持requirejs。在

    window.Zepto = Zepto
    '$' in window || (window.$ = Zepto)
    

    后增加如下代码,以便支持requirejs

    if ( typeof define === "function" && define.amd ) {
        define( "zepto", [], function () { return Zepto; } );
    }
    

    3、加入如下代码,以支持微信等部分浏览器的滑动

    if (touch.x2 && Math.abs(touch.x1 - touch.x2) > 10){
          e.preventDefault()
        }
    

    在如下方法中增加

    .on('touchmove MSPointerMove pointermove', function(e){
        if((_isPointerType = isPointerEventType(e, 'move')) &&
          !isPrimaryTouch(e)) return
        firstTouch = _isPointerType ? e : e.touches[0]
        cancelLongTap()
        touch.x2 = firstTouch.pageX
        touch.y2 = firstTouch.pageY
    
        deltaX += Math.abs(touch.x1 - touch.x2)
        deltaY += Math.abs(touch.y1 - touch.y2)
    
        if (touch.x2 && Math.abs(touch.x1 - touch.x2) > 10){
          e.preventDefault()
        }
      })
    

    详情见:https://github.com/jnotnull/zepto

    4、因IOS在第三方输入法下不支持onkeyup事件,所以需要使用oninput进行代替onkeyup事件

    $("#user-name")[0].oninput = function() {
          that.checkusername();
        };
    

    5、使用fastclick代替zepto的tap事件,防止出现穿透问题。

  • 相关阅读:
    3.1C#中的命名空间
    2章总结
    2.4冒泡排序
    2.3 C#中的数组
    2.2二重循环
    2.1c#中的循环语句
    1章总结
    docker内外数据拷贝
    搭建docker环境
    centos7 部署Apache的httpd服务器
  • 原文地址:https://www.cnblogs.com/chris-oil/p/8996483.html
Copyright © 2011-2022 走看看