mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 12:41:20 -08:00
update isInViewport
This commit is contained in:
1 parent
2ea92640aa
commit
115467ecc5
3 files changed
+5
-5
No files matched your search
@@ -69,8 +69,8 @@ export function isInViewport(el, offset = 0) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
||||
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
||||
const vertInView = rect.top <= windowHeight + offset && rect.top + rect.height + offset >= 0;
|
||||
const horInView = rect.left <= windowWidth + offset && rect.left + rect.width + offset >= 0;
|
||||
const vertInView = rect.top - offset <= windowHeight && rect.top + rect.height + offset >= 0;
|
||||
const horInView = rect.left - offset <= windowWidth + offset && rect.left + rect.width + offset >= 0;
|
||||
return vertInView && horInView;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user