zoukankan      html  css  js  c++  java
  • JQuery Mobile iscroll插件使用教程及注意事项

    中文文档:http://www.360doc.com/content/14/0724/11/16276861_396699901.shtml

    问题:使用了iscroll之后,你会发现点击输入框时不灵敏,经常无法聚焦;页面文字也无法选择和复制。这是由于iscroll要监听鼠标事件和触摸事件来进行滚动,所以禁止了浏览器的默认行为 ,包含在wrapper中的input、Seclect控件无法选择或点击

    解决办法:
    在创建Scorll时,定义以下方法

    onBeforeScrollStart: function (e) { 
    var target = e.target; 
    while (target.nodeType != 1) target = target.parentNode; 
    if (target.tagName != ‘SELECT’ && target.tagName != ‘INPUT’ && target.tagName != ‘TEXTAREA’) 
    e.preventDefault(); 
    }, 

    完整代码:

    /**
     * 初始化iScroll控件
     */
    function loaded() {
        pullUpEl = document.getElementById('pullUp');
        pullUpOffset = pullUpEl.offsetHeight;
        myScroll = new iScroll('wrapper', {
            useTransition: false, /* 防止更新时闪动 */
            topOffset: pullDownOffset,
            onRefresh: function () {
                if (pullUpEl.className.match('loading')) {
                    pullUpEl.className = 'tips';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
                }
            },
            onScrollMove: function () {
                if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
                    pullUpEl.className = 'flip tips';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '松手开始更新...';
                    this.maxScrollY = this.maxScrollY;
                } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
                    pullUpEl.className = 'tips';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
                    this.maxScrollY = pullUpOffset;
                }
            },
            onScrollEnd: function () {
                if (pullUpEl.className.match('flip')) {
                    pullUpEl.className = 'loading tips';
                    pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中...';                
                    pullUpAction();    // Execute custom function (ajax call?)
                }
            },
            onBeforeScrollStart: function (e) {
                var target = e.target;
                while (target.nodeType != 1) target = target.parentNode;
                if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA')
                e.preventDefault();
            }
        });
        
        setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 500);
    }
    
    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    document.addEventListener('DOMContentLoaded', loaded, false); //初始化绑定iScroll控件 
    点点滴滴,终汇一海
  • 相关阅读:
    C# 自定义文件图标 双击启动 (修改注册表)
    C/S打包 客户端/windows程序 InstallShield
    WPF 依赖属性
    WPF 自定义Expander
    WPF DevExpress ChartControl用法
    WPF 水平进度条
    WPF 自定义CheckBox
    WPF 自定义ListBox
    WPF 绕圈进度条(一)
    1.为什么要用泛型
  • 原文地址:https://www.cnblogs.com/forever-cjs/p/5133190.html
Copyright © 2011-2022 走看看