Skip to content

Commit c2a9a31

Browse files
committed
feat($uiViewScroll): change function to return promise
return the promise from the timeout for additional processing Closes #1702
1 parent d9c3a95 commit c2a9a31

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/viewScroll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function $ViewScrollProvider() {
4242
}
4343

4444
return function ($element) {
45-
$timeout(function () {
45+
return $timeout(function () {
4646
$element[0].scrollIntoView();
4747
}, 0, false);
4848
};

test/viewScrollSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ describe('uiView', function () {
1717
$timeout.flush();
1818
expect(elem[0].scrollIntoView).toHaveBeenCalled();
1919
}));
20+
21+
it('should return the promise from the timeout', inject(function ($uiViewScroll, $timeout) {
22+
var promise = $uiViewScroll(elem);
23+
24+
$timeout.flush();
25+
expect(elem[0].scrollIntoView).toHaveBeenCalled();
26+
expect(promise).toBeDefined();
27+
}));
2028
});
2129

2230
describe('useAnchorScroll', function () {

0 commit comments

Comments
 (0)