在父级给 document 添加 mousemove 时间,实现一个拖拽功能。当拖到 iframe 上方时,发现变得卡顿,开始还以为是代码要优化,后来发现是 iframe 搞的鬼。解决方法也很简单,在 mousedown 和 mouseup 给 iframe 添加个样式
function onMouseDown() {
document.querySelector('iframe').style['pointer-events'] = 'none'
// ...
}
function onMouseUp() {
document.querySelector('iframe').style['pointer-events'] = 'auto'
// ...
}