Touchenter and touchleave support

I read about the events of touchhenter and touchleave, on the mozilla and w3 website , but cannot find a browser to support it or any javascript library that mimics this effect.

Please suggest what can be done as a workaround, since I'm working on some mouseover effect, the event fires when the fingers enter the element, and not when the user lifts and touches the elements again.

Thanks:)

+4
javascript html5 google-chrome web-applications
source share
4 answers

I suggest you use

document.elementFromPoint(touch.x, touch.y);

in the touchmove event.

+10
source share
+5
source share

There is a list here indicating version compatibility. Chrome, Opera, iOS Safari, Android Browser, Blackberry Browser, Opera Mobile, Chrome for Android, Firefox for android currently support this feature.

0
source share

W3C removes ontouchenter and ontouchleave, so we can only do this (with zepto.js, touch.js, ontouchmove, elementFromPoint):

 var last_touched_button=''; $('#container,#button1,#button2').on('touchmove',function(e){ var ele=document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY); if (ele==document.getElementById('button1')) {last_touched_button='button1'; } else if (ele==document.getElementById('button2')) {last_touched_button='button2'; } }); $('#container,#button1,#button2').on('swipeLeft',function(e){ console.log('the button '+last_touched_button+' triggered swipe_into_left_side event or swipe_out_from_left_side event!'); }); 
0
source share

All Articles