Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. $(document).scroll(function(e){
  2. var $window = $(window)
  3. var $authors = $('.author')
  4. if($authors.length > 0) {
  5. $authors.each(function(i, e) {
  6. var $author = $(e)
  7. var $container = $author.parent().parent()
  8. var offset = Math.max(0, $window.scrollTop() - $container.offset().top + 50)
  9. offset = Math.min($container.height() + $container.offset().top - $author.outerHeight() - 50, offset)
  10. var currentOffset = parseFloat($author[0].style.top)
  11. if(offset !== currentOffset) {
  12. $author.css({top:offset})
  13. }
  14. })
  15. }
  16. }).scroll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement