The div tag css is set to foverflow-y:scroll;-webkit-overflow-scrolling:touch; 」 and is set to inertially scroll part of the screen in iOS webview.
I create a list or table in the div tag and specify the event to transition to a different page by touchstart or touchend, but when I tap during inertial scrolling, the line in the display position before inertial scrolling is tapped and transitioned to an unintended page.
If I tap during inertial scrolling, what kind of event setting should I use to tap the line as shown on the screen?
*If you scroll the entire screen instead of part of the screen, it will work as expected.
Here is a simple sample code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div { border:1px solid; width: 100%; height:500px; overflow-y:auto;-webkit-overflow-scrolling:touch;}
ul { list-style: none;}
li {height:150px; border-bottom:1px solid;}
</style>
<script type="text/javascript">
varonLoad=function(){
elements = document.getElementsByTagName('li');
for (vari=0; i<elements.length;i++) {
elements[i].addEventListener('touchstart', function(e){
console.log(e.target.innerText);
});
}
};
</script>
</head>
<body onLoad="onLoad()">
<div>
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
<li>f</li>
<li>g>/li>
<li>h</li>
<li>i>/li>
<li>j</li>
<li>k</li>
<li>l>/li>
<li>m</li>
<li>n</li>
</ul>
</div>
</body>
</html>
It's a self-answer.
It's been a while since I posted it, but
According to the subsequent investigation, it only happens in the case of UIWebview.
For browsers (Safari, Chrome) and WKWebview, I was able to get the tap position successfully.
There may be some kind of method, but this time I will solve it myself because it is a UI Webview specification.
Thank you.
© 2024 OneMinuteCode. All rights reserved.