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

Function scroll

test/angular/1.7/angular.js:5413–5429  ·  view source on GitHub ↗
(hash)

Source from the content-addressed store, hash-verified

5411 }
5412
5413 function scroll(hash) {
5414 // Allow numeric hashes
5415 hash = isString(hash) ? hash : isNumber(hash) ? hash.toString() : $location.hash();
5416 var elm;
5417
5418 // empty hash, scroll to the top of the page
5419 if (!hash) scrollTo(null);
5420
5421 // element with given id
5422 else if ((elm = document.getElementById(hash))) scrollTo(elm);
5423
5424 // first anchor with given name :-D
5425 else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm);
5426
5427 // no element and hash === 'top', scroll to the top of the page
5428 else if (hash === 'top') scrollTo(null);
5429 }
5430
5431 // does not scroll when user clicks on anchor link that is currently on
5432 // (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