Google FastButton clicks twice on iOS

前端 未结 2 1074
再見小時候
再見小時候 2021-01-17 02:48

When using MrMaksimize and Alex Blacks implementation of Google FastButton I get two clicks in iOS.

Try this fiddle: http://jsfiddle.net/Cotten/zQsVZ/



        
2条回答
  •  独厮守ぢ
    2021-01-17 03:06

    I'm having a similar issue here.

    I was able to fix it by using this solution:

    var clickObject = {
        flag: false,
        isAlreadyClicked: function () {
            var wasClicked = clickObject.flag;
            clickObject.flag = true;
            setTimeout(function () { clickObject.flag = false; }, 100);
            return wasClicked;
        }
    };
    var a = new FastButton(document.getElementById('a'), function() {
        if (!clickObject.isAlreadyClicked()) {
            alert('click');
        } else {
            return;
        }
    });
    

    I'm not sure if it will work with your fast button implementation, but it's worth a shot. My implementation look more like this:

    $('#container').on('click touchstart', 'a.element', function(event) {
        if (!clickObject.isAlreadyClicked()) {
            alert('click');
        } else {
            return;
        }
    });
    

    Best of luck!

提交回复
热议问题