Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- var element = $('#faq'),
- originalY = element.offset().top;
- // Space between element and top of screen (when scrolling)
- var topMargin = 500;
- // Should probably be set in CSS; but here just for emphasis
- element.css('position', 'relative');
- $(window).on('scroll', function(event) {
- var scrollTop = $(window).scrollTop();
- element.stop(false, false).animate({
- top: scrollTop < originalY
- ? 0
- : scrollTop - originalY + topMargin
- }, 200);
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement