Created
April 7, 2017 06:31
-
-
Save npofopr/d3a57c36019cba8a94a661590201e91f 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
$(window).scroll(function() { | |
var sb_m = 20; // отступ сверху и снизу | |
var mb = 500; // высота подвала с запасом | |
var st = $(window).scrollTop(); | |
var sb = $(".sticky-block"); | |
var sbi = $(".sticky-block .inner"); | |
var sb_ot = sb.offset().top; | |
var sbi_ot = sbi.offset().top; | |
var sb_h = sb.height(); | |
if (sb_h + $(document).scrollTop() + sb_m + mb < $(document).height()) { | |
if (st > sb_ot) { | |
var h = Math.round(st - sb_ot) + sb_m; | |
sb.css({ "paddingTop": h }); | |
} else { | |
sb.css({ "paddingTop": 0 }); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment