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!'); });
diyism
source share