Skip to content

Instantly share code, notes, and snippets.

@trevorhreed
Created February 22, 2017 17:25
Show Gist options
  • Save trevorhreed/41303c7ae95e09630f97dee500f4072c to your computer and use it in GitHub Desktop.
Save trevorhreed/41303c7ae95e09630f97dee500f4072c to your computer and use it in GitHub Desktop.
Scroll percentage, infinite scroll
// 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