Skip to content

Commit

Permalink
fix(uiView): Do NOT autoscroll when autoscroll attr is missing
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timkindberg committed Mar 7, 2014
1 parent 4d74d98 commit affe5bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@
* Examples for `autoscroll`:
*
* <pre>
* <!-- If autoscroll unspecified, then scroll ui-view into view
* (Note: this default behavior is under review and may be reversed) -->
* <ui-view/>
*
* <!-- If autoscroll present with no expression,
* then scroll ui-view into view -->
* <ui-view autoscroll/>
Expand Down Expand Up @@ -214,7 +210,7 @@ function $ViewDirective( $state, $injector, $uiViewScroll) {

var clone = $transclude(newScope, function(clone) {
renderer.enter(clone, $element, function onUiViewEnter() {
if (!angular.isDefined(autoScrollExp) || !autoScrollExp || scope.$eval(autoScrollExp)) {
if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
$uiViewScroll(clone);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ describe('uiView', function () {
});

describe('autoscroll attribute', function () {
it('should autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
it('should NOT autoscroll when unspecified', inject(function ($state, $q, $uiViewScroll, $animate) {
elem.append($compile('<div><ui-view></ui-view></div>')(scope));

$state.transitionTo(aState);
$q.flush();

if ($animate) $animate.triggerCallbacks();

expect($uiViewScroll).toHaveBeenCalledWith(elem.find('span').parent());
expect($uiViewScroll).not.toHaveBeenCalled();
}));

it('should autoscroll when expression is missing', inject(function ($state, $q, $uiViewScroll, $animate) {
Expand Down

0 comments on commit affe5bd

Please sign in to comment.