-
Notifications
You must be signed in to change notification settings - Fork 0
/
lazyload.js
33 lines (26 loc) · 1007 Bytes
/
lazyload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* vanilla-lazyload API reference:
* https://github.com/verlok/vanilla-lazyload#options
*/
document.addEventListener('DOMContentLoaded', () => {
const lazyLoad = new LazyLoad({
elements_selector: '.lazyload',
// called whenever an element finishes loading
callback_loaded: (el) => {
const wrapper = el.closest('.lazyload-wrapper')
if (wrapper) {
wrapper.classList.add('loaded')
}
},
// called whenever an element starts loading:
// callback_loading: (el) => {}
// called whenever an element triggers an error:
// callback_error: (el) => {}
// called whenever an element enters the viewport
// callback_enter: (el) => {}
// called whenever an element exits the viewport
// callback_exit: (el) => {}
// called when there are no more elements to load and all elements have been downloaded:
// callback_finish: () => {}
})
})