codepen & js demos
Mutation Observer & customize resize event listener & demo
https://codepen.io/webgeeker/pen/YjrZgg
Mutation Observer
https://javascript.ruanyifeng.com/dom/mutationobserver.html
https://developer.mozilla.org/zh-CN/docs/Web/API/MutationObserver
// todo
resize & response width
https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event
const heightOutput = document.querySelector('#height');
const widthOutput = document.querySelector('#width');
function reportWindowSize() {
heightOutput.textContent = window.innerHeight;
widthOutput.textContent = window.innerWidth;
}
window.onresize = reportWindowSize;
// OR
window.addEventListener('resize', reportWindowSize);
https://codepen.io/xgqfrms/pen/dyyWrWb?&editable=true
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!