0

I'm using ui-scroll-to

I need to scroll this smoothly. also it should stop before 100px in mentioned element.

<a ui-scroll-to="msg-container" >
   Go to Msg
</a>

<div id="msg-container">
   msgs
</div>

smooth scroll like .scrollTop() in jquery

  • 1
    u can just use jquery i don't think angular has something like that. I had the same problem and I've used jQuery. Another alternative is to make your own directive with does the scroll with jquery so you can use it in different places – Radu Jan 04 '16 at 07:24

1 Answers1

0

Something like this should work. You might have to tweak the target.offset().top a bit if you have a fixed header or something similar that might mess with the offset.

app.config(function ($provide) {
  $provide.decorator('$uiViewScroll', function ($delegate) {
    return function (uiViewElement) {
        $('html,body').animate({
            scrollTop: uiViewElement.offset().top
        }, 500);
    };
  });
});

Keep autoscroll="true" on your ui-view.

See other answer for credit on the prodiver: Angular ui-router scroll to top, not to ui-view.

Community
  • 1
  • 1
Fahed Alkaabi
  • 269
  • 2
  • 10