Advertisement
MiG39

Untitled

May 21st, 2020
1,313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var scrollingOffset = function() {
  2.         var headerHeight = $('.header').outerHeight();
  3.         var id = window.location.hash.substr(1);
  4.        
  5.         $('.mainmenu a[href*="#"]').on('click', function(e) {
  6.             var anchor = $(this.hash);
  7.            
  8.             if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') ||location.hostname == this.hostname) {
  9.               anchor = anchor.length ? anchor : $('[name=' + this.hash.slice(1) + ']');
  10.               if (anchor.length) {
  11.                 $("html, body").animate({
  12.                   scrollTop: anchor.offset().top - headerHeight
  13.                 }, 1500);
  14.                 return false;
  15.               }
  16.             }
  17.            
  18.         });
  19.        
  20.         if (id != '' && $('#'+id).length>0) {
  21.           if(id.indexOf('comment')>=0)$('.tab-product a[href="#reviews"]').tab('show');
  22.           $("html, body").animate({
  23.             scrollTop: $("#" + id).offset().top - headerHeight
  24.         }, 1500);}
  25.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement