Can't click on links with Iscroll 5

user3162341 picture user3162341 · Mar 8, 2014 · Viewed 9.8k times · Source

i'm using Iscroll 5, i can scroll with this code, i have no problem. The only problem is with my iphone i can't click on the link, and i don't know why...

<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>

If i use this code i can click but i can't scroll ...

<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>

Answer

maksim.lin picture maksim.lin · Jul 8, 2014

Set the click option of the Iscroll on true

IScroll click documentation

myScroll = new IScroll('#youDIV',
                {
                    scrollX: false, 
                    scrollY: true
                    ,click:true // open click event
                    ,scrollbars: false 
                    ,useTransform: true
                    ,useTransition: false
                    ,probeType:3
                });