Created
November 20, 2015 08:13
-
-
Save d1i1m1o1n/fb486d115f37aa07e2f8 to your computer and use it in GitHub Desktop.
Fixed block while scroll page
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
//Фиксируем форму обратной связи | |
var $section_of_form = $("#fixed_scroll_form").closest('section'), | |
fixed_scroll_form = $section_of_form.offset().top - 50; | |
//Выставляем текущую ширину | |
$section_of_form.css('width', $section_of_form.css('width')); | |
$(window).bind("scroll", function() { | |
var offset = $(this).scrollTop(); | |
if (offset >= fixed_scroll_form && !$section_of_form.hasClass("fixed_scroll_form")) { | |
$section_of_form.addClass('fixed_scroll_form'); | |
} else if (offset < fixed_scroll_form) { | |
$section_of_form.removeClass('fixed_scroll_form'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment