AngularJS - $anchorScroll smooth/duration

后端 未结 7 1312
你的背包
你的背包 2020-12-04 07:52

Reading the AngularJS docs I haven\'t figured out if $anchorScroll can have a duration/easing option to smooth scroll to elements.

It only says:

相关标签:
7条回答
  • 2020-12-04 08:26

    The answer from Brett worked great for me. I did some small changes on his solution in terms of modularization and testability.

    Here's is yet another working example on JsFiddle that includes the other version with testing included.

    For testing, I'm using Karma and Jasmine. Signature has been slightly modified as follows:

     anchorSmoothScroll.scrollTo(elementId, speed);
    

    Where element is a mandatory attribute to scroll to and speed is optional where the default is 20 (as it was before).

    0 讨论(0)
提交回复
热议问题