Created
February 22, 2017 17:25
-
-
Save trevorhreed/41303c7ae95e09630f97dee500f4072c to your computer and use it in GitHub Desktop.
Scroll percentage, infinite scroll
This file contains hidden or 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
// This code is for infinite scrolling, which we may or may not implement | |
var wrapper = $('.test-scroll-wrapper'); | |
var content = $('.test-scroll-content'); | |
window.wrapper = wrapper; | |
window.content = content; | |
wrapper.on('scroll', function(){ | |
var marginTop = Math.round(parseFloat(content.css('marginTop'))); | |
var marginBottom = Math.round(parseFloat(content.css('marginBottom'))); | |
var height = content.height() + marginTop + marginBottom - wrapper.height(); | |
var pos = wrapper.scrollTop(); | |
var percent = pos / height; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment