3 * @name ui.router.state.$uiViewScrollProvider
6 * Provider that returns the {@link ui.router.state.$uiViewScroll} service function.
8 function $ViewScrollProvider() {
10 var useAnchorScroll = false;
14 * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll
15 * @methodOf ui.router.state.$uiViewScrollProvider
18 * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for
19 * scrolling based on the url anchor.
21 this.useAnchorScroll = function () {
22 useAnchorScroll = true;
27 * @name ui.router.state.$uiViewScroll
29 * @requires $anchorScroll
33 * When called with a jqLite element, it scrolls the element into view (after a
34 * `$timeout` so the DOM has time to refresh).
36 * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
37 * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}.
39 this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
40 if (useAnchorScroll) {
44 return function ($element) {
45 return $timeout(function () {
46 $element[0].scrollIntoView();
52 angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);