1***@qq.com
1***@qq.com
  • 发布:2018-05-09 10:44
  • 更新:2018-08-20 13:33
  • 阅读:2353

下拉刷新和picker下滑冲突

分类:MUI

我的代码:
<div class="mui-content" id="pullrefresh">
<button id='demo5' data-options='{"type":"time"}' class="btn mui-btn mui-btn-block">选择时间 ...</button>
<div type="text" id="inp"/>请选择</div>
</div>
<script src="js/mui.min.js"></script>
<script src="js/zepto.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.picker.min.js"></script>
<script type="text/javascript">
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
style:'circle',
callback: pulldownRefresh
}
}
});
function pulldownRefresh(){
setTimeout(function(){
mui('#pullrefresh').pullRefresh().endPulldown();
},1000)
}
//打开时间选择器
var inp = $('#inp');
mui(".mui-content").on('tap','#demo5',function(){
if(mui.os.ios|| mui.os.ipad || mui.os.iphone||mui.os.android) {
//此代码的作用是为了解决使用单WEBVIEW下拉刷新时与日历插件的冲突;
mui('#pullrefresh').pullRefresh().scrollTo(0,10,100);
}
var dtPicker = new mui.DtPicker({"type":"time"});
dtPicker.show(function (selectItems) {
inp.text(selectItems.text)
dtPicker.dispose();
})
},false)
</script>

怎么当picker组件跳出禁止下拉刷新呢?
我尝试的方法:
在点击弹出加上mui("#pullrefresh").pullRefresh().setStopped(true),没用,直接报错:Cannot set property 'className' of undefined at

js/mui.min.js:8。求大神分享解决办法

2018-05-09 10:44 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

你的问题解决了嘛?请问怎么处理的?

p***@yahoo.com

p***@yahoo.com

我有个很无语的解决方案,安卓模拟器下测试有效:


    // jamesp  
    /**  
     * 防止下拉冲突.  
     * 增加options.pullRefresh配置, show的时候暂时禁用pullRefresh  
     */  
    var show = DtPicker.prototype.show;  
    DtPicker.prototype.show = function(){  
        if(this.options.pullRefresh){  
            this.options.pullRefresh && mui(this.options.pullRefresh).pullRefresh().setStopped(true);  
            // hack: 页面向下scroll 1像素  
            var dom = document.querySelector(this.options.pullRefresh);  
            if(dom.scrollTop == 0){  
                dom.old_Height = dom.style.height;  
                dom.style.height = '999px';  
                window.scrollTo(0, 1);  
            }  
        }  
        show.apply(this);  
    };  
    var hide = DtPicker.prototype.hide;  
    DtPicker.prototype.hide = function(){  
        if(this.options.pullRefresh){  
            mui(this.options.pullRefresh).pullRefresh().setStopped(false);  
            // hack  
            var dom = document.querySelector(this.options.pullRefresh);  
            if(dom.hasOwnProperty('old_Height')) {  
                dom.style.height = dom.old_Height;  
                delete dom.old_Height;  
                window.scrollTo(0, 0);  
            }  
            hide.apply(this);  
        }  
    };  
  • p***@yahoo.com

    更正下show参数忘了

    DtPicker.prototype.show = function(cb){

    try{

    if(this.options.pullRefresh){

    this.options.pullRefresh && mui(this.options.pullRefresh).pullRefresh().setStopped(true);

    // hack

    var dom = document.querySelector(this.options.pullRefresh);

    if(dom.scrollTop == 0){

    dom.old_Height = dom.style.height;

    dom.style.height = '999px';

    window.scrollTo(0, 1);

    }

    }

    }catch(e){console.error(e);}

    show.call(this, cb);

    };

    2018-08-20 14:14

该问题目前已经被锁定, 无法添加新回复