MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / scroll

Function scroll

web/static/bower_components/angular/angular.js:4741–4756  ·  view source on GitHub ↗
(hash)

Source from the content-addressed store, hash-verified

4739 }
4740
4741 function scroll(hash) {
4742 hash = isString(hash) ? hash : $location.hash();
4743 var elm;
4744
4745 // empty hash, scroll to the top of the page
4746 if (!hash) scrollTo(null);
4747
4748 // element with given id
4749 else if ((elm = document.getElementById(hash))) scrollTo(elm);
4750
4751 // first anchor with given name :-D
4752 else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm);
4753
4754 // no element and hash == 'top', scroll to the top of the page
4755 else if (hash === 'top') scrollTo(null);
4756 }
4757
4758 // does not scroll when user clicks on anchor link that is currently on
4759 // (no url change, no $location.hash() change), browser native does scroll

Callers

nothing calls this directly

Calls 3

isStringFunction · 0.85
scrollToFunction · 0.85
getFirstAnchorFunction · 0.85

Tested by

no test coverage detected