forked from jgthms/css-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.js
More file actions
23 lines (20 loc) · 719 Bytes
/
Copy pathsingle.js
File metadata and controls
23 lines (20 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener('DOMContentLoaded', function() {
var $root = document.documentElement;
var toTravel = $root.scrollHeight - window.innerHeight;
var $bsaShadow = document.getElementById('bsaShadow');
var menuThrottle = null;
if ($bsaShadow) {
document.addEventListener('scroll', function(event) {
clearTimeout(menuThrottle);
throttle = setTimeout(setBsaShadows(), 100);
});
function setBsaShadows() {
var scrollTop = window.scrollY;
var distance = toTravel - scrollTop;
var topFactor = 1 - (distance / toTravel);
$bsaShadow.style.opacity = topFactor;
$bsaShadow.style.transform = 'scaleY(' + topFactor + ')';
}
setBsaShadows();
}
});