vendredi 13 février 2015

Using lodash updatePosition not working


Hello So I am using lodash for the first time. My jquery code keeps jumping and I am trying to migrate it in the lodash function but I don't really understand how.


IDK if this matter but the main idea behind the code is for a div to scroll down to a position and snap to place but it keeps jumping. please advise !!



$(window).on('scroll', _.throttle(updatePosition, 100));

$(window).on('scroll', function(){
var scroll = $(window).scrollTop();

var sectionPosTop = document.getElementById('header-bamboo-scroll').getBoundingClientRect();

var headerHeight = document.getElementById('header').getBoundingClientRect();


if (scroll >= 660 && scroll <= 680 ) {
console.log('greater than 660 and less than 680');
$('html, body').animate({
scrollTop: headerHeight.height
}, 500, function() {
$('html, body').stop();
});
}

});
});




Aucun commentaire:

Enregistrer un commentaire