MCPcopy
hub / github.com/angular-ui/ui-router / scroll

Function scroll

test/angular/1.4/angular.js:4833–4848  ·  view source on GitHub ↗
(hash)

Source from the content-addressed store, hash-verified

4831 }
4832
4833 function scroll(hash) {
4834 hash = isString(hash) ? hash : $location.hash();
4835 var elm;
4836
4837 // empty hash, scroll to the top of the page
4838 if (!hash) scrollTo(null);
4839
4840 // element with given id
4841 else if ((elm = document.getElementById(hash))) scrollTo(elm);
4842
4843 // first anchor with given name :-D
4844 else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm);
4845
4846 // no element and hash == 'top', scroll to the top of the page
4847 else if (hash === 'top') scrollTo(null);
4848 }
4849
4850 // does not scroll when user clicks on anchor link that is currently on
4851 // (no url change, no $location.hash() change), browser native does scroll

Callers

nothing calls this directly

Calls 3

isStringFunction · 0.70
scrollToFunction · 0.70
getFirstAnchorFunction · 0.70

Tested by

no test coverage detected