Skip to content

Commit

Permalink
feat($uiViewScroll): change function to return promise
Browse files Browse the repository at this point in the history
return the promise from the timeout for additional processing

Closes angular-ui#1702
  • Loading branch information
mikef438 committed Jan 22, 2015
1 parent d9c3a95 commit c2a9a31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/viewScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function $ViewScrollProvider() {
}

return function ($element) {
$timeout(function () {
return $timeout(function () {
$element[0].scrollIntoView();
}, 0, false);
};
Expand Down
8 changes: 8 additions & 0 deletions test/viewScrollSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ describe('uiView', function () {
$timeout.flush();
expect(elem[0].scrollIntoView).toHaveBeenCalled();
}));

it('should return the promise from the timeout', inject(function ($uiViewScroll, $timeout) {
var promise = $uiViewScroll(elem);

$timeout.flush();
expect(elem[0].scrollIntoView).toHaveBeenCalled();
expect(promise).toBeDefined();
}));
});

describe('useAnchorScroll', function () {
Expand Down

0 comments on commit c2a9a31

Please sign in to comment.