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:
Lukas Eipert 2018-11-26 14:26:23 +01:00
parent 1c1b7a820d
commit ab83c1e419
No known key found for this signature in database
GPG Key ID: 148BEA37CB35B2AC
2 changed files with 8 additions and 1 deletions

View File

@ -91,7 +91,9 @@ export default class LazyLoader {
onIntersection = entries => {
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.lazyImages.push(entry.target);
}

View File

@ -0,0 +1,5 @@
---
title: Fix Image Lazy Loader for some older browsers
merge_request:
author:
type: fixed