rexjiang92
8/14/2017 - 9:19 PM

animate inside page shift

<script>
$( document ).ready(function() { 
	

	// smooth scroll 
	$(function() {
	  var height = $("#pre-header-wrapper").outerHeight();
	  if ($("body").hasClass("logged-in")){
	    var heightLoggedin = $(".admin-navbar-collapse").outerHeight();
	    height += heightLoggedin;
	  }
	  height += 60;
	  $('#block-aw_custom-0 .dropdown-menu a').click(function() {
	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
	      var target = $(this.hash);
	      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
	      if (target.length) {
	        $('html, body').animate({
	          scrollTop: target.offset().top - height
	        }, 1000);
	        return false;
	      }
        }
	  });

	if(window.location.hash) {
        // smooth scroll to the anchor id
        $('html, body').animate({
	        scrollTop: $(window.location.hash).offset().top - height
	    }, 1000);
	
	}

	});
});
</script>