Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Commit 4708549

Browse files
author
Greg Whitworth
committed
Fixed safari console errors which was keeping the animation from occurring
1 parent 67b28b8 commit 4708549

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

variable-fonts/scripts/var-fonts.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,17 @@ let waitForFonts = document.fonts && document.fonts.ready ? document.fonts.ready
278278
}
279279
};
280280

281-
const guideHeaders = document.querySelectorAll('.guide-content h2');
282-
const guideHeadersObserver = new IntersectionObserver((entries) => {
283-
return entries.forEach((e) => {
284-
animateHeader(e.target, e.intersectionRatio);
285-
});
286-
}, { threshold: 0.3 });
287-
for (const guideHeader of guideHeaders) {
288-
guideHeadersObserver.observe(guideHeader);
289-
guideHeadersObserver.observe(guideHeader.closest('section'));
281+
if ('IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
282+
const guideHeaders = document.querySelectorAll('.guide-content h2');
283+
const guideHeadersObserver = new IntersectionObserver((entries) => {
284+
return entries.forEach((e) => {
285+
animateHeader(e.target, e.intersectionRatio);
286+
});
287+
}, { threshold: 0.3 });
288+
for (const guideHeader of guideHeaders) {
289+
guideHeadersObserver.observe(guideHeader);
290+
guideHeadersObserver.observe(guideHeader.closest('section'));
291+
}
290292
}
291293

292294
// DETECT GRADIENT TRANSITION SUPPORT
@@ -329,14 +331,16 @@ let waitForFonts = document.fonts && document.fonts.ready ? document.fonts.ready
329331
});
330332

331333
// also start once scrolling has revealed 10% of the poem
332-
const poemZoneObserver = new IntersectionObserver((entries) => {
333-
return entries.forEach((e) => {
334-
if (e.intersectionRatio >= 0.1) {
335-
startIceDriftAnimation();
336-
}
337-
});
338-
}, { threshold: 0.1 });
339-
poemZoneObserver.observe(document.querySelector('#poem'));
334+
if ('IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
335+
const poemZoneObserver = new IntersectionObserver((entries) => {
336+
return entries.forEach((e) => {
337+
if (e.intersectionRatio >= 0.1) {
338+
startIceDriftAnimation();
339+
}
340+
});
341+
}, { threshold: 0.1 });
342+
poemZoneObserver.observe(document.querySelector('#poem'));
343+
}
340344
}());
341345

342346
/*

0 commit comments

Comments
 (0)