Hi there,
i was cleaning a site a bit up and noticed that when i use the links to references on other pages, smoothScroll is added in the url path. Did a simple fix for that.
How it was
After the fix
Adjusted code
$(document).ready(function () {
// Call $.smoothScroll if location.hash starts with "#smoothScroll"
//var reSmooth = /^#smoothScroll/;
var reSmooth = /^#smoothScroll/;
var tag = /^#/;
var id;
if (reSmooth.test(location.hash)){
// ADD FOCUS FOR TAG
id = '#' + location.hash.replace(reSmooth, '');
$(id).css('border-bottom', '4px solid #00aeef');
$(id).css('padding-bottom', '1px');
}
if (reSmooth.test(location.hash)) {
// Strip the "#smoothScroll" part off (and put "#" back on the beginning)
id = '#' + location.hash.replace(reSmooth, '');
// Strip the "#smoothScroll" part off path
location.hash = location.hash.replace(reSmooth, '');
$.smoothScroll({
scrollTarget: id,
offset: -100
});
}
else if (tag.test(location.hash)) {
// Strip the "#smoothScroll" part off (and put "#" back on the beginning)
id = location.hash;
// Strip the "#smoothScroll" part off path
location.hash = location.hash.replace(reSmooth, '');
$.smoothScroll({
scrollTarget: id,
offset: -100
});
}
});
Hi there, i was cleaning a site a bit up and noticed that when i use the links to references on other pages, smoothScroll is added in the url path. Did a simple fix for that.
How it was
After the fix
Adjusted code