Can';t单击带有Iscroll 5的链接

Can';t单击带有Iscroll 5的链接,scroll,iscroll,Scroll,Iscroll,我使用的是Iscroll 5,我可以滚动这个代码,我没有问题。 唯一的问题是我的iphone无法点击链接,我不知道为什么 <script type="text/javascript"> var scroll; function loaded() { scroll = new IScroll('#contenu', { tap:true, desktopCompatibility: true, scrollbars: true,

我使用的是Iscroll 5,我可以滚动这个代码,我没有问题。 唯一的问题是我的iphone无法点击链接,我不知道为什么

<script type="text/javascript">
var scroll;
function loaded() {
    scroll = new IScroll('#contenu', {
    tap:true,
    desktopCompatibility: true,
        scrollbars: true,
        interactiveScrollbars: true,
        freeScroll: true,
        scrollX: true,
        scrollY: true,
        momentum: false,
        onBeforeScrollStart: null,
        mouseWheel: true
    });
}

//disables browser mouse scrolling
if (window.addEventListener) {
    window.addEventListener('DOMMouseScroll', wheel, false);
}

function wheel(event) {
    event.preventDefault();
    event.returnValue = false;
}

window.onmousewheel = document.onmousewheel = wheel;
</script>

变量卷轴;
函数加载(){
滚动=新的IScroll(“#contenu”{
塔普:没错,
桌面兼容性:正确,
滚动条:对,
交互滚动条:对,
弗里斯克罗尔:没错,
是的,
是的,
动量:错,
onBeforeScrollStart:null,
鼠标滚轮:对
});
}
//禁用浏览器鼠标滚动
if(window.addEventListener){
window.addEventListener('DOMMouseScroll',wheel,false);
}
功能控制盘(事件){
event.preventDefault();
event.returnValue=false;
}
window.onmouseheel=document.onmouseheel=wheel;
如果我使用此代码,我可以单击但不能滚动

<script type="text/javascript">
var myScroll;
var showkey =true;
function loaded () {
    myScroll = new IScroll('#contenu', { 
    tap:true,
    desktopCompatibility: true,
    onBeforeScrollStart: function (e) {
                var nodeType = e.explicitOriginalTarget ? e.explicitOriginalTarget.nodeName.toLowerCase():(e.target ? e.target.nodeName.toLowerCase():'');

                if(nodeType !='select' && nodeType !='option' && nodeType !='input' && nodeType!='textarea' && !showkey) {
                     e.preventDefault();    //prevents showing keyboard - scrolling
                }//otherwise, show keyboard, do default
                if(!showkey) showkey = true;
            },       
    });
    $('a, input, #sendmsg, .ml_tabs').on('touchstart', function(e) {
        e.stopPropagation();
    });
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', function () { setTimeout(iScrollLoad, 200); }, false);
</script>

迈斯克罗尔变种;
var showkey=true;
已加载函数(){
myScroll=newiscroll('#contenu',{
塔普:没错,
桌面兼容性:正确,
OnBeforeCollStart:函数(e){
var nodeType=e.explicitOriginalTarget?e.explicitOriginalTarget.nodeName.toLowerCase():(e.target?e.target.nodeName.toLowerCase():“”);
if(nodeType!='select'&&nodeType!='option'&&nodeType!='input'&&nodeType!='textarea'&&showkey){
e、 preventDefault();//防止显示键盘滚动
}//否则,显示键盘,执行默认设置
如果(!showkey)showkey=true;
},       
});
$('a,input,#sendmsg,.ml_制表符')。打开('touchstart',函数(e){
e、 停止传播();
});
}
addEventListener('touchmove',函数(e){e.preventDefault();},false);
addEventListener('DOMContentLoaded',function(){setTimeout(iScrollLoad,200);},false);

1:您可以提供一个JSFIDLE,以检查代码的错误

2:为什么要通过添加eventlisteners来禁用鼠标滚动?只要设置
mouseweel:false
就可以了

3:iScroll捕获touchmove事件并进行处理,以决定用户想要做什么。因此,在初始化iScroll时添加以下内容:

document.addEventListener('touchmove',函数(e){e.preventDefault();},false)

4:我不明白,为什么要设置custo eventhandler,比如
onBeforeScrollStart:null
这毫无意义。 例如,如果某个对话打开(如a),您可以在不想滚动时启用禁用iScroll,如下所示:

myScroll.on('BeforeCrollStart',函数(事件) { 如果(isDialogOpen){ 禁用(); } 否则{ enable(); } });

5:例如,
上的简单单击事件处理程序应按预期工作

$(document).on(“tap”、“#mydiv”,函数(e){
e、 预防默认值();
警报(“mydiv已单击!”);
});

6:初始化iScroll时使用
preventDefault:false,//不要阻止可能的单击-我们会处理它

将iScroll的单击选项设置为true

“maksim.lin”说得对!!我不允许投票:

但是“click:true”是最好的,因为添加“preventDefault:false”可以完成这项工作,但它会导致鼠标(如果使用PC)选择滚动之外的元素(文本选择和侧滚动会变得急促)。“Click:true”修复了移动电话上的问题,不会在PC上产生选择问题。

{…Click:true,}
成功解决了问题。在过去的4个小时里疯了。谢谢+今天晚上,这个答案为我解决了这个问题。
myScroll = new IScroll('#youDIV',
                {
                    scrollX: false, 
                    scrollY: true
                    ,click:true // open click event
                    ,scrollbars: false 
                    ,useTransform: true
                    ,useTransition: false
                    ,probeType:3
                });