Material Design Lite and jQuery, smooth scroll not working

后端 未结 2 978
余生分开走
余生分开走 2020-12-16 07:43

I am unable to use .animate method of jQuery with Google\'s Material Design Lite(MDL). I have used MDL to make navigation bar, but smooth scrolling was not working.

2条回答
  •  难免孤独
    2020-12-16 08:08

    The reason you are not seeing anything happen is because you are scrolling on the body node. MDL handles the overflow within the mdl-layout__content, this is the element you should scroll on.

    So this -

    $("html, body").animate({scrollTop:position}, speed, "swing");
    

    Now becomes-

    $(".mdl-layout__content").animate({scrollTop:position}, speed, "swing");
    

    Here's a codepen example - http://codepen.io/mdlhut/pen/BNeoVa

提交回复
热议问题