From c2a9a311388bb212e5a2e820536d1d739f829ccd Mon Sep 17 00:00:00 2001 From: dookie86 Date: Thu, 22 Jan 2015 13:58:07 -0500 Subject: [PATCH] feat($uiViewScroll): change function to return promise return the promise from the timeout for additional processing Closes #1702 --- src/viewScroll.js | 2 +- test/viewScrollSpec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/viewScroll.js b/src/viewScroll.js index dfe0a030d..81114e20d 100644 --- a/src/viewScroll.js +++ b/src/viewScroll.js @@ -42,7 +42,7 @@ function $ViewScrollProvider() { } return function ($element) { - $timeout(function () { + return $timeout(function () { $element[0].scrollIntoView(); }, 0, false); }; diff --git a/test/viewScrollSpec.js b/test/viewScrollSpec.js index c46cae198..f51a0c7fe 100644 --- a/test/viewScrollSpec.js +++ b/test/viewScrollSpec.js @@ -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 () {