Created
February 21, 2017 21:53
-
-
Save Caaz/ed1baedfb6ada267c9e0dbca34709f65 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
$(document).scroll(function(e){ | |
var $window = $(window) | |
var $authors = $('.author') | |
if($authors.length > 0) { | |
$authors.each(function(i, e) { | |
var $author = $(e) | |
var $container = $author.parent().parent() | |
var offset = Math.max(0, $window.scrollTop() - $container.offset().top + 50) | |
offset = Math.min($container.height() + $container.offset().top - $author.outerHeight() - 50, offset) | |
var currentOffset = parseFloat($author[0].style.top) | |
if(offset !== currentOffset) { | |
$author.css({top:offset}) | |
} | |
}) | |
} | |
}).scroll() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment