MCPcopy Index your code
hub / github.com/angular-ui/ui-router / scroll

Function scroll

test/angular/1.5/angular.js:5041–5057  ·  view source on GitHub ↗
(hash)

Source from the content-addressed store, hash-verified

5039 }
5040
5041 function scroll(hash) {
5042 // Allow numeric hashes
5043 hash = isString(hash) ? hash : isNumber(hash) ? hash.toString() : $location.hash();
5044 var elm;
5045
5046 // empty hash, scroll to the top of the page
5047 if (!hash) scrollTo(null);
5048
5049 // element with given id
5050 else if ((elm = document.getElementById(hash))) scrollTo(elm);
5051
5052 // first anchor with given name :-D
5053 else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm);
5054
5055 // no element and hash === 'top', scroll to the top of the page
5056 else if (hash === 'top') scrollTo(null);
5057 }
5058
5059 // does not scroll when user clicks on anchor link that is currently on
5060 // (no url change, no $location.hash() change), browser native does scroll

Callers

nothing calls this directly

Calls 4

isStringFunction · 0.70
isNumberFunction · 0.70
scrollToFunction · 0.70
getFirstAnchorFunction · 0.70

Tested by

no test coverage detected