-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.js
49 lines (39 loc) · 1.19 KB
/
layout.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// layout.js controls all of the scrolling animation behavior
"use strict";
(function() {
window.addEventListener('load', init);
function init() {
if (window.innerWidth > 700) {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
// entry.target.classList.remove('show');
}
})
})
const hiddenElements = qsa('.hide');
hiddenElements.forEach((element) => observer.observe(element));
const hiddenElements2 = qsa('.hide-long');
hiddenElements2.forEach((element) => observer.observe(element));
}
}
/**
* If the browser is Safari, returns true
*/
function isSafari() {
// Check if the browser is Safari
let isSafari = window.safari !== undefined;
let isIphone = /(iPhone)/i.test(navigator.userAgent);
return isSafari && isIphone;
}
/**
* Returns all of the selectors
* @param {selector} all of the selectors selected
* @returns {selector} all of the selectors
*/
function qsa(selector) {
return document.querySelectorAll(selector);
}
})();