mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 19:41:25 -08:00
refactor(core): CORE-17 type input events and own interaction lifetimes
This commit is contained in:
1 parent
88aef830df
commit
a842058136
72 files changed
+31156
-1219
No files matched your search
@@ -0,0 +1,11 @@
|
||||
export function inViewport(element: HTMLElement, offset: number): boolean {
|
||||
const rect = element.getBoundingClientRect()
|
||||
const document = element.ownerDocument
|
||||
const window = document.defaultView
|
||||
const height = window?.innerHeight || document.documentElement.clientHeight
|
||||
const width = window?.innerWidth || document.documentElement.clientWidth
|
||||
// Retain the historical edge/gap calculations while using the actual owner viewport.
|
||||
const vertical = rect.top - offset <= height && rect.top + rect.height + offset >= 0
|
||||
const horizontal = rect.left - offset <= width + offset && rect.left + rect.width + offset >= 0
|
||||
return vertical && horizontal
|
||||
}
|
||||
Reference in new issue
Block a user