javascript - Unified and transparent pointer events in jQuery -
i have bootstrap .btn
want toggle mouse click. problem response way slow on tablets, since click
arrives 300 ms after touchstart
in mobile browsers.
i tried binding logic in touchstart
event, breaking app desktop browsers there no touchstart
. thought of binding same logic click
repeated event in mobile browsers. i've juggling around, trying unbind click
first time receive touchstart
, , on, , managed come design complicated there quirk here or there cannot solve.
for instance, can't text input receive focus in tablet: if focus on touchstart
click
event returns focus button. tried jquery mobile's vmousedown
, couldn't manage have multi-touch (tapping more 1 button @ same time changed 1 of them). don't want reinvent lot of wheels, , i'm sure must missing obvious, either on jquery mobile, or plain javascript.
in concrete, want event vmousedown
works both on desktops , mobiles, fires once on each, , allows multi-touch.
utilize modernizr handling actions based on device, etc. provides great cross-browser/platform support without need sniff user agents , like. instead, uses feature detection.
you can use modernizr functions jquery's $(document).ready(function()});
$(function(){ if (modernizr.touch){ // bind touchstart, touchmove, etc , watch `event.streamid` } else { // bind normal click, mousemove, etc } });
this code has been taken straight modernizr documentation
also, here's resource performing touch tests
Comments
Post a Comment