获取当前滚动元素
function findscroller(element) {
element.onscroll = function () {
// 返回当前滚动元素\
console.log(element);
};
Array.from(element.children).forEach(findscroller);
}
findscroller(document.body)
获取要滚动元素的距离
const getOffsetSize = function (Node: any, offset?: any): any {
if (!offset) {
offset = {
x: 0,
y: 0,
};
}
if (Node === document.body) return offset;
offset.x += Node.offsetLeft;
offset.y += Node.offsetTop;
return getOffsetSize(Node.offsetParent, offset);
};