Created
July 24, 2018 14:55
-
-
Save rafaelcavalcante/ed2a64b6af01469ad14b13b849974245 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
jQuery(document).ready(function(){ | |
jQuery(window).on('scroll', function(){ | |
var scrollTop = jQuery(window).scrollTop(); | |
var windowHeight = jQuery(window).height(); | |
var windowAxis = scrollTop + (windowHeight / 2); | |
jQuery('[data-bubble]').each(function(){ | |
var height = jQuery(this).height(); | |
var top = jQuery(this).offset().top; | |
var axis = top + ( height / 2); | |
var ratio = parseFloat(jQuery(this).attr('data-ratio')); | |
var calculus = (windowAxis - axis) * ratio; | |
jQuery(this).css('transform', 'translateY(' + parseInt(calculus) + 'px)'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment