【发布时间】:2020-08-19 12:37:19
【问题描述】:
在 iPhone 上的 Safari 上,如果您快速滚动页面,则在滚动停止之前不会处理 白框 事件。
(要查看此错误,您需要通过滑动来滚动页面并尝试在页面仍在滚动时触摸白色框。要查看预期行为,请尝试在不滚动页面的情况下触摸它。)
const fix = document.querySelector('.fix')
const text = document.querySelector('.handle')
fix.addEventListener('touchstart', handle)
fix.addEventListener('touchend', handle)
fix.addEventListener('mousedown', handle)
fix.addEventListener('touchmove', handle)
function handle(e){
text.innerText = e.type
console.log(e)
}
.scroll{
width: 100%;
height: 2000vh;
background: rgb(226,252,193);
background: linear-gradient(0deg, rgba(226,252,193,1) 0%, rgba(182,251,176,1) 3%, rgba(204,128,151,1) 49%, rgba(134,133,189,1) 75%, rgba(71,153,222,1) 98%, rgba(0,204,247,1) 100%);
}
*{
padding: 0;
margin: 0;
}
.fix{
position: fixed;
display: flex;
align-items: center;
justify-content: center;
bottom: 0;
left: 0;
right: 0;
height: 150px;
background-color: #fff;
}
.handle{
font-size: 20px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Old versions of Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
<section class="scroll"></section>
<div class="fix">
<p class="handle"></p>
</div>
【问题讨论】:
-
这在其他设备上工作正常吗?
-
我在 android 上测试 - 它工作正常
-
但在 IOS 中不工作
标签: javascript touch mobile-safari touch-event