Плавная прокрутка страницы лэндинга на основе jQuery




Обратите внимание на меню сверху ↑

HTML

<a class="active" href="#BlogArchive1" title="">Архив</a>

JQUERY

(function($){
$(function(){
$('#block-system-main-menu td a').click(function(e){
$('#block-system-main-menu td a').removeClass('active_scroll');
$(this).addClass('active_scroll');
var href = $(this).attr('href');
var _pos = href.indexOf('#');
var win_h = $('#block-system-main-menu').height();
if(_pos >= 0) {
href = href.substring(_pos);
var elem = $(href);
if(elem.length) {
var top = elem.offset().top - win_h;;
var win_top = $(window).scrollTop();
if(win_top > 1200){
var scroll_time = 3000;
} else {
var scroll_time = Math.abs(win_top - top);
}
$('html, body').animate({scrollTop : top + 'px'}, scroll_time);
e.preventDefault();
}
}
});
})
})
(jQuery)

Комментариев нет :

Отправить комментарий