Use intersectionRatio to determine intersection
Some older browsers do not ship with isIntersecting, while they already have IntersectionObserver support. We make use of `intersectionRatio` now to fix the Lazy Loader for those browsers.
This commit is contained in:
parent
1c1b7a820d
commit
ab83c1e419
|
@ -91,7 +91,9 @@ export default class LazyLoader {
|
||||||
|
|
||||||
onIntersection = entries => {
|
onIntersection = entries => {
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
if (entry.isIntersecting) {
|
// We are using `intersectionRatio > 0` over `isIntersecting`, as some browsers did not ship the latter
|
||||||
|
// See: https://gitlab.com/gitlab-org/gitlab-ce/issues/54407
|
||||||
|
if (entry.intersectionRatio > 0) {
|
||||||
this.intersectionObserver.unobserve(entry.target);
|
this.intersectionObserver.unobserve(entry.target);
|
||||||
this.lazyImages.push(entry.target);
|
this.lazyImages.push(entry.target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix Image Lazy Loader for some older browsers
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
Loading…
Reference in New Issue