Apple users often report that I often have to click several times to get in
, no matter whether I use @tap @click
, add a cursor pointer to any style, or try any delegation, but it doesn’t work
I finally tried the touch event and found that it could solve my problem. uncomfortable
It's better to use touch events on the mobile side.
@touchend I just use this event to handle it.
Finally, a pit that is often encountered is the problem that both hands and double-clicks can still be enlarged after ios10.
Almighty netizens
<script>
window.onload = function () {
// 阻止双击放大
var lastTouchEnd = 0;
document.addEventListener('touchstart', function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
});
document.addEventListener('touchend', function (event) {
var now = (new Date()).getTime();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, false);
// 阻止双指放大
document.addEventListener('gesturestart', function (event) {
event.preventDefault();
});
}
</script>
Follow me to continuously update front-end knowledge. I've been feeling a little sick recently. I may not update the blog very much in the future.