Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default view scroll to off when autoscroll attr not specified #807

Closed
timkindberg opened this issue Jan 23, 2014 · 14 comments · Fixed by #932
Closed

Default view scroll to off when autoscroll attr not specified #807

timkindberg opened this issue Jan 23, 2014 · 14 comments · Fixed by #932
Labels
Milestone

Comments

@timkindberg
Copy link
Contributor

See discussion in #720

If the autoscroll attr is not specified then no scrolling should occur.

@schmod
Copy link

schmod commented Jan 27, 2014

Ideally, I think that developers should be able to specify the "default" behavior in the .config block of their application.

As long as that's provided, I don't think that it matters which behavior ui-router uses out of the box... As long as we can easily override it.

@wejendorp
Copy link

I agree, I'd like it to be a .config option.

@timkindberg
Copy link
Contributor Author

So maybe eliminate the $uiViewScrollProvider.useAnchorScroll() and give these options?

//scrolls to nothing when no autoscroll attrs are present
$uiViewScrollProvider.defaultScroll = 'none'; 

//scrolls to last populated view when no autoscroll attrs are present
$uiViewScrollProvider.defaultScroll = 'view'; 

//scrolls to anchor from url when no autoscroll attrs are present
//this would revert back to regular $anchorScroll behavior
$uiViewScrollProvider.defaultScroll = 'anchor'; 

@nateabele
Copy link
Contributor

-1 for magical hardcoded values. The way it is now follows Angular core conventions and is extensible through existing interfaces.

@timkindberg
Copy link
Contributor Author

But we should probably still turn the scroll bit off by default. I think more people would rather it be off.

@mokkabonna
Copy link

I think it should be off by default, or at least have the option to turn it off for all views in the config phase. Right now I'm stuck with updating all my views with autoscroll="false"

@nocksock
Copy link

nocksock commented Feb 7, 2014

+1 for off by default.

@nateabele
Copy link
Contributor

But we should probably still turn the scroll bit off by default. I think more people would rather it be off.

That's fine with me.

@timkindberg timkindberg self-assigned this Feb 12, 2014
@austencollins
Copy link

+1 For turning it off. I just lost a few hours to figuring out why my pages were loading scrolled down. It was starting to kill my self-esteem as a programmer! Otherwise, I love ui-router, thanks for making it :)

@CharlesHamel
Copy link

+1 For turning it off

@martijnve
Copy link

@ac360 I had the exact same problem. Something like this should either be off by default or in the first page of the quick-start guide to not confuse people. At the very least there should be an easy way to turn it off globally.

In the meantime I "fixed" it with this code in my module.config:

$uiViewScrollProvider.useAnchorScroll();
$anchorScrollProvider.disableAutoScrolling();

@austencollins
Copy link

@martijnve Agreed. You can also turn off the autoscroll by adding the autoscroll="false" attribute to your ui-view tags:

< div ui-view="header" autoscroll="false">
< div ui-view="content" autoscroll="false">

tlvince added a commit to tlvince/LMIS-Chrome that referenced this issue Feb 21, 2014
timkindberg added a commit that referenced this issue Mar 6, 2014
Breaking Change: If you had ui-views that you wanted to autoscroll to on state change, you may now need to explicitly add `autoscroll="true"`. Fixes #807
@albertboada
Copy link

+1 for off by default.

Official ngRoute's ngView does not autoscroll by default, so it is logic that uiView here does not either. Otherwise, developers get very confused, as we all have been.

However, if uiView is wanted to have autoscroll on by default, it should be plain easy to globally disable this behaviour, but that's clearly not the case right now.


Besides, as much as I try, I still don't get what $uiViewScrollProvider.useAnchorScroll() is aimed for. It looks like an intend to revert to the default ngRoute's ngView behaviour, but fails at it:

  • Default ngRoute's behaviour (ngView):
  1. Updates ngView
  2. Does not call $anchorScroll service because ngView's autoscroll attr is not set, so ngRoute's default behaviour is applied (ngView.js#L233).

Result: no scroll at all.

  • Default Ui-Router behaviour (uiView):
  1. Updates uiView
  2. Calls $uiViewScroll() (viewDirective.js#L169), which ends up calling default Ui-Router scrolling script (viewScroll.js#L30).

Result: autoscrolls to the uiView.

  • Default Ui-Router behaviour (uiView) + useAnchorScroll:
  1. Updates uiView
  2. Executes $uiViewScroll(), which ends up calling AngularJS's $anchorScroll() (viewScroll.js#L25)

Result: scrolls to anchor (scrolls to page-top if no anchor).

If uiView's autoscroll behaviour is finally set to false by default, $uiViewScrollProvider.useAnchorScroll() will start making sense again because it will make uiView match AngularJS's ngView default behaviour.

timkindberg added a commit that referenced this issue Mar 7, 2014
Breaking Change: If you had ui-views that you wanted to autoscroll to on state change, you may now need to explicitly add `autoscroll="true"`. Fixes #807
timkindberg added a commit that referenced this issue Mar 7, 2014
Breaking Change: If you had ui-views that you wanted to autoscroll to on state change, you may now need to explicitly add `autoscroll="true"`. Fixes #807
@christopherthielen christopherthielen modified the milestones: 0.3.0, 0.2.11 Aug 27, 2014
@shaileshmalgunde
Copy link

+1 for off by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.