MCPcopy Create free account
hub / github.com/binux/qiandao / scroll

Function scroll

web/static/components/angularjs/angular.js:4040–4054  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4038 }
4039
4040 function scroll() {
4041 var hash = $location.hash(), elm;
4042
4043 // empty hash, scroll to the top of the page
4044 if (!hash) $window.scrollTo(0, 0);
4045
4046 // element with given id
4047 else if ((elm = document.getElementById(hash))) elm.scrollIntoView();
4048
4049 // first anchor with given name :-D
4050 else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) elm.scrollIntoView();
4051
4052 // no element and hash == 'top', scroll to the top of the page
4053 else if (hash === 'top') $window.scrollTo(0, 0);
4054 }
4055
4056 // does not scroll when user clicks on anchor link that is currently on
4057 // (no url change, no $location.hash() change), browser native does scroll

Callers

nothing calls this directly

Calls 1

getFirstAnchorFunction · 0.85

Tested by

no test coverage detected