Google FastButton clicks twice on iOS

前端 未结 2 1076
再見小時候
再見小時候 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:27

    I think the FastButton implementation already prevents the Ghostclick (timeout of a few milliseconds).

    I had the same problem, as I think the problem might be in the fact that you're using and alert (as I was). For some reason (I haven't dived deep into the code), you get another event fired because of the alert. If you're only trying the code out, use "console.log" which is non-blocking instead of alert, and you might see that this second event does not get called.

    Hopefully the idea is not to use the alert command, but if it is, use it with a timeout, which works around the implementation of ghostclick, which is what i think is breaking the behaviour anyway:

    new FastButton(document.getElementById('a'), function() { 
           setTimeout('alert("hello");',500);
    });
    

    Hope it helps.

    Cheers, Miguel

提交回复
热议问题