Created
October 25, 2019 04:17
-
-
Save Risyandi/a124a257e7f77eb92532d523eb384218 to your computer and use it in GitHub Desktop.
a method trigger when scrolling and minimum height of display.
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
/* | |
* targetId : is target of element, get based on ID/class/query element. | |
* htmlBody : count all body HTML. | |
*/ | |
function triggerScroll() { | |
let targetId = document.getElementById('topStickyWrapper'); | |
let htmlBody = document.documentElement; | |
window.addEventListener('scroll', function () { | |
if (htmlBody.scrollTop > 200 && htmlBody.scrollTop < 1000) { | |
targetId.classList.add('topStickyFloating'); | |
} else { | |
targetId.classList.remove('topStickyFloating'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment