我有这个代码:
$(window).scroll(function () {
if ($(this).scrollTop() > ($animate.headline.height() + 100)) {
$animate.header.velocity({height: "50px"}, { queue: false });
} else {
$animate.header.velocity({height: "100px"}, { queue: false });
}
});
如果用户从顶部滚动 xxx 像素,则动画应该开始,并且效果很好。
我刚刚注意到的一件事让我很困扰 - 每次滚动时,速度动画都会检查 scrollTop,所以当我滚动时整体动画并不流畅,因为在触发动画之前,函数正在检查滚动。
有没有其他方法可以让它平滑?
例子: