Created
November 24, 2016 02:49
-
-
Save hugofabricio/4efbd953037a3b83b78583efc32d3f7c to your computer and use it in GitHub Desktop.
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
(function ($) { | |
$.fn.progressBar = function(){ | |
return this.each(function() { | |
var bar = this, | |
bar_progress = $(bar).find('.loading'); | |
$(window).scroll(function(){ | |
if(scrolledIntoView(bar)){ | |
var each_bar_width = bar_progress.attr('aria-valuenow'); | |
bar_progress.width(each_bar_width + '%'); | |
}; | |
}); | |
}); | |
}; | |
function scrolledIntoView( element ) { | |
var docViewTop = $(window).scrollTop(), | |
docViewBottom = docViewTop + $(window).height(), | |
elemTop = $(element).offset().top, | |
elemBottom = elemTop + $(element).height(); | |
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop)); | |
}; | |
}( jQuery )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment