javascript - Angular ui-router scroll to top, not to ui-view -
i've upgraded ui-router 0.2.8
0.2.0
, i've noticed when state changes, scroll position jumps top of te child ui-view
subject of new state.
this fine have 2 problems it:
1) have 30px padding between top of page , ui-view
, scroll top of page, leaving gap. @ moment goes top of ui-view
looks ugly. achieve guess either need know how scroll top of div ui-view in (not browser viewport
), or need find out how override $uiviewscroll
scroll ui-view
minus 30px.
i have tried $uiviewscrollprovider.useanchorscroll();
if doesn't scroll @ all. have tried <ui-view autoscroll="false">;
, stops scrolling completely.
2) doesn't scroll @ moment, jumps. suppose scroll or developer css transitions?
any appreciated :)
another approach decorate default $uiviewscroll
service, overriding default behaviour.
app.config(function ($provide) { $provide.decorator('$uiviewscroll', function ($delegate) { return function (uiviewelement) { // var top = uiviewelement.getboundingclientrect().top; // window.scrollto(0, (top - 30)); // or other custom behaviour... }; }); });
and hubrus mentioned, <ui-view>
not wish apply for, add autoscroll="false"
. haven't taken actual scrolling implementation, figured i'd mention decorator way (it's alot of fun) alternative. i'm sure can work out exact scrolling behaviour.
Comments
Post a Comment