In my Android application, the user can view some HTML pages using the ViewPager, and the user can touch the item to be highlighted.
The problem is trying to get a touch event using javascript using the following code, elementFromPoint returns null when going to a new page, but after the user zooms in or scrolls the page, it works correctly.
I found that the touchstart event register occurs after zooming or scrolling the page. so it works right after that, although it is registered at $ (document) .ready ()
$(document).ready(function(){ document.addEventListener("touchstart", touchstart, false); }); function touchstart(e) { var x = e.targetTouches[0].clientX; var y = e.targetTouches[0].clientY; el = document.elementFromPoint(x, y); }
thanks
source share