JS监听DOM位置移动

阅读 87

2022-08-03


const config = { attributes: true, childList: true, subtree: true };
const callback = (mutationsList, observer) => {
let getBoundingClientRect = this.getBoundingClientRect()
console.log('postion', `left: ${getBoundingClientRect.left}`, `bottom: ${getBoundingClientRect.bottom}`, mutationsList)
};
const observer = new MutationObserver(callback);
observer.observe(this, config);


精彩评论(0)

0 0 举报