Skip to content

Commit 51c18ab

Browse files
committed
refactor: ♻️ refactor code
1 parent f83df10 commit 51c18ab

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

js/main-en.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,8 @@
379379
}
380380

381381
// 處理中間圖片跟隨視窗大小移動位置
382-
window.onresize = function () {
383-
watchChangeSize();
384-
}
385-
386-
function watchChangeSize() {
387-
const offsetWidth = document.documentElement.clientWidth;
388-
if (offsetWidth) {
389-
location.reload();
390-
}
391-
}
382+
window.addEventListener('resize', () => {
383+
document.documentElement.clientWidth = location.reload();
384+
});
392385

393386
}();

js/main.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,8 @@
379379
}
380380

381381
// 處理中間圖片跟隨視窗大小移動位置
382-
window.onresize = function () {
383-
watchChangeSize();
384-
}
385-
386-
function watchChangeSize() {
387-
const offsetWidth = document.documentElement.clientWidth;
388-
if (offsetWidth) {
389-
location.reload();
390-
}
391-
}
382+
window.addEventListener('resize', () => {
383+
document.documentElement.clientWidth = location.reload();
384+
});
392385

393386
}();

0 commit comments

Comments
 (0)