Archived topic
Smooth scroll breaks full path anchor links with hash
13 replies · Started by Mike on May 18, 2018
It seems the new smooth-scroll class works as intended if the anchor link is the simple a href="#id"
But if I use it on a full link like this:
a herf="http://www.mysite.com/#id" or a relative root path like /path/#id
Then clicking the link simply does nothing at all. The link becomes "dead".
As you can see, sometimes we do need to use the full path links for things like in the navigation menu, because not all the anchors will be on the same page. If it won't do smooth scroll when pointed to a different page, it should at least follow the link, so basically smooth if the user is on the same page, and no smooth if on different page.
Could you please take a look into this?
Thanks.
That's strange - I can't replicate that issue. Can you add the URL to your site within the URL field of your original post?
Hello Tom,
I updated the URL of my development site. The link examples in question:
"Why Choose Us" on the top menu has just the relative #link, it works.
"Industries" has full path. It doesn't work.
Thanks.
Hi Mike, i think smooth scroll is for use with the GP navigation and not the mega menu, which looking at the markup seems it has its own smooth scroll function (?)
The Max Mega Menu doesn't have its own smooth scroll, it just copies every CSS class of the menu and add a mega- prefix to them. The basic smooth-scroll class still remains.
I tried non-menu links. For example, links in the body of the page (see the "common issues" link), and it behaves the same. Full path + smooth-scroll = dead link.
Thanks.
So let's look at the common issues button. If you remove the / from in front of the URL, it works?
I'll dig into the code and see if I can find the issue.
Yes sir, removing / and it works, just like the green and blue buttons.
I also tried disabling Autoptimize, no difference.
I then deactivated every single plugin I have (Autoptimize, Max Mega Menu, Smart Slider 3), leaving only GP of course:), no difference either.
Thanks for the additional info - will look into it ASAP :)
Is this something that happens with my site only? Do full path links with hash tags like http://yoursite.com/#link with the new GP smooth-scroll class added and smooth-scroll enabled work for everyone else?
The full URL like that should work fine.
On your site, it seemed you only had a slash in front of the anchor.
Changed to full URL and doesn't work. It was actually through the full URL that I found out it didn't work...
Anything except straight away #tag doesn't seem to work.
That's really strange - here's what I'm getting: http://tomusborne.com/dev/?page_id=13766
I wonder if there's a conflicting smooth scroll script on your site?
I solved it—by upgrading to GP Premium 1.6.2 from 1.6.1. I just realized I was still on 1.6.1 because I run IIS and have to delete GP/re-install GP every time I want to upgrade GP due to that long directory name bug.
But I didn't upgrade because I thought 1.6.2 was the same as 1.6.1 except for the PHP warning for GP sites issue. Because I didn't have that problem I thought I'd just skip 1.6.2 and wait for 1.6.3.
But who knows upgrading to 1.6.2 actually solved the problem. Something must have changed between .1 and .2 I guess. What a coincidence.
Thanks Tom for the effort to look into my issue.
Strange - nothing changed in the script between those two versions. Maybe updating cleared some caches.
Glad it's working now :)