Created
January 17, 2019 02:14
-
-
Save pudly/ac227f95480e820a7c7734fa9d6c8f2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $featured_nav = document.querySelector('.post--featured > nav'); | |
if ($featured_nav) { | |
$featured_nav.addEventListener('scroll', function() { | |
var fw = $featured_nav.scrollWidth; | |
var fc = $featured_nav.scrollLeft; | |
var fm = $featured_nav.clientWidth; | |
$featured_nav.classList.remove('__notscrolled'); | |
if (fc > (fw - fm - 40)) { | |
$featured_nav.classList.remove('__right'); | |
$featured_nav.classList.add('__left'); | |
} | |
else if (fc == 0) { | |
$featured_nav.classList.remove('__left'); | |
$featured_nav.classList.add('__right'); | |
} | |
else { | |
$featured_nav.classList.add('__right'); | |
$featured_nav.classList.add('__left'); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment