티스토리 뷰



http://phonegapblog.blogspot.kr/2013/07/phonegap-galaxy-s4-handles-taps-as.html


https://groups.google.com/forum/#!msg/phonegap/eNd_eFpPY2o/unj_2-DXK-0J





ere's how I solved the onclick-problem. Possibly not the best way, but in my case it was easy to implement.


So. This link would be fired twice. We don't want that.

<div onClick="myFunction();">a bad button</div>


So, instead I changed all my links to this:

<div onClick="attemptClick('myFunction()');">a nice button</div>


And then I added this JavaScript to filter the clicks..

            var clickLock = false;

            

            function attemptClick(funcName) {

                if(!clickLock) {

                    clickLock = true;

                    setTimeout(funcName,0);

                    setTimeout('resetClickLock()',300);

                }else {

                    alert("Double tap prevented!"); //Only for debugging ofc, remove!

                }

            }

            

            function resetClickLock() {

                clickLock = false;

                alert("no more lock"); //Only for debugging ofc, remove!

            }


If anyone have a better solution, please let me know! :-)



Den torsdagen den 4:e juli 2013 kl. 13:55:45 UTC+2 skrev Tor Claesson:







Changed the JavaScript a bit, this works better..


var clickLock = false;

            

            function attemptClick(funcName) {

                if(!clickLock) {

                    clickLock = true;

                    setTimeout("queueClick("+funcName+")",100);

                    setTimeout('resetClickLock()',1000);

                }else {

                }

            }

            

            function queueClick(funcName) {

                if(!clickLock) {

                    setTimeout(funcName,0);

                }else {

                }

            }

            

            function resetClickLock() {

                clickLock = false;

            }


Den fredagen den 5:e juli 2013 kl. 14:56:20 UTC+2 skrev Tor Claesson:

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함