Using helps from this forum I solved redirecting to anchor on different page and smooth scrolling with offsetting the top menu on the same page.
However, the redirecting to anchor on another page doesn't offset. The site user lands 130 pixels under the anchor in the Storefront template if the anchor is on another page.
I use this js obtained here: https://www.gavick.com/forums/storefron ... tion-48636
- Code: Select all
// smooth anchor scrolling
jQuery('a[href*="#"]').on('click', function (e) {
e.preventDefault();
if(this.hash !== '') {
var target = jQuery(this.hash);
if(this.hash !== '' && this.href.replace(this.hash, '') == window.location.href.replace(window.location.hash, '')) {
if(target.length && this.hash !== '#') {
jQuery('html, body').stop().animate({
'scrollTop': target.offset().top-133
}, 1000, 'swing', function () {
if(this.hash !== '#') {
history.pushState({}, '', target.selector);
}
});
} else if(this.hash !== '' && this.href.replace(this.hash, '') !== '') {
window.location.href = this.href;
}
} else if(this.hash !== '' && this.href.replace(this.hash, '') !== '') {
window.location.href = this.href;
}
}
});
}
Any help appreciated.