开发者

jquery scrolltop animation flips on click but then scrolls smoothly

I've set up this function:

      $(func开发者_如何学编程tion() {
      $('.top a').bind('click',function(event){
          var $anchor = $(this);

          $('html, body').stop().animate({
              scrollTop: $($anchor.attr('href')).offset().top
          }, 5000,'easeInOutExpo');
          event.preventDefault();
      });
  });

It does work well but online when I click it it jumps like some pixels up first and then scrolls smoothly to the top.

There is no margin or padding wether on the body nor on the wrapper. The div I'm targeting is the first element on the page and the one I'm starting from right at the bottom and outside the wrapper.

What about that little flip at first?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜