Skip to content

Commit fc5ab35

Browse files
committed
Improve intersection observers
1 parent 001594b commit fc5ab35

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

css/application.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/complete.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/application.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/application.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ window.addEventListener('scroll.rAF', fcn_throttle(fcn_scrollDirection, 200));
478478

479479
// Main observer
480480
const /** @const {IntersectionObserver} */ fcn_mainObserver = new IntersectionObserver(
481-
([e]) => fcn_theBody.classList.toggle('is-inside-main', e.intersectionRatio < 1),
481+
([e]) => {
482+
fcn_theBody.classList.toggle('is-inside-main', e.intersectionRatio < 1 && e.boundingClientRect.top <= 0);
483+
},
482484
{ threshold: [1] }
483485
);
484486

src/scss/_navigation.scss

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
.nav-observer {
2+
visibility: hidden;
23
position: absolute;
34
top: calc(-1px + var(--nav-observer-offset, 0px));
4-
left: 0;
5-
z-index: -1000;
6-
height: 1px;
7-
width: 1px;
8-
transform: translateZ(0); // Improve performance
95
}
106

117
@include bp(601px) {

0 commit comments

Comments
 (0)