mirror of
https://github.com/youzan/vant.git
synced 2025-12-20 01:01:34 +08:00
[bugfix] popup scrollable element (#429)
This commit is contained in:
@@ -23,18 +23,22 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
// 找到最近的触发滚动事件的元素
|
||||
getScrollEventTarget(element) {
|
||||
/* 找到最近的触发滚动事件的元素
|
||||
* @param {Element} element
|
||||
* @param {Element} rootElement
|
||||
* @return {Element | window}
|
||||
*/
|
||||
getScrollEventTarget(element, rootParent = window) {
|
||||
let currentNode = element;
|
||||
// bugfix, see http://w3help.org/zh-cn/causes/SD9013 and http://stackoverflow.com/questions/17016740/onscroll-function-is-not-working-for-chrome
|
||||
while (currentNode && currentNode.tagName !== 'HTML' && currentNode.tagName !== 'BODY' && currentNode.nodeType === 1) {
|
||||
while (currentNode && currentNode.tagName !== 'HTML' && currentNode.tagName !== 'BODY' && currentNode.nodeType === 1 && currentNode !== rootParent) {
|
||||
const overflowY = this.getComputedStyle(currentNode).overflowY;
|
||||
if (overflowY === 'scroll' || overflowY === 'auto') {
|
||||
return currentNode;
|
||||
}
|
||||
currentNode = currentNode.parentNode;
|
||||
}
|
||||
return window;
|
||||
return rootParent;
|
||||
},
|
||||
|
||||
// 判断元素是否被加入到页面节点内
|
||||
|
||||
Reference in New Issue
Block a user