Skip to content

Commit f801e18

Browse files
committed
pref: use IntersectionObserver API instead of scroll event
1 parent 072a39a commit f801e18

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/utils/lazy-load.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ class LazyLoader {
99
}
1010

1111
public observe() {
12-
const { el, handler } = this
13-
1412
const cb = (entries: IntersectionObserverEntry[]) => {
1513
const entry = entries[0]
16-
if (entry.intersectionRatio > 0) handler()
14+
if (entry.intersectionRatio > 0) this.handler()
1715
}
1816

1917
this.intersectionObserver = new IntersectionObserver(cb)
20-
this.intersectionObserver.observe(el)
18+
this.intersectionObserver.observe(this.el)
2119
}
2220

2321
public unobserve() {

0 commit comments

Comments
 (0)