scrollIfAnchor: function()

in amplify-theme/assets/js/scripts.js [35:56]


	  scrollIfAnchor: function(href, pushToHistory) {
		var match, rect, anchorOffset;
  
		if(!this.ANCHOR_REGEX.test(href)) {
		  return false;
		}
  
		match = document.getElementById(href.slice(1));
  
		if(match) {
		  rect = match.getBoundingClientRect();
		  anchorOffset = window.pageYOffset + rect.top - this.getFixedOffset();
		  window.scrollTo(window.pageXOffset, anchorOffset);
  
		  // Add the state to history as-per normal anchor links
		  if(HISTORY_SUPPORT && pushToHistory) {
			history.pushState({}, document.title, location.pathname + href);
		  }
		}
  
		return !!match;
	  },