Anchor link in mobile not working anymore
-
Hello!
I couldn't find anything on this specific problem so I post here.
I used the code for anchor scroll animations found on this website:<script> window.laytheme.on('newpageshown', function(){ if(window.location.hash.length > 0){ var id = window.location.hash; if(jQuery(id).length > 0){ jQuery('html, body').animate( { scrollTop: jQuery(id).offset().top-70 }, { duration: 1200 }); } } }); </script>
In the beginning everything worked fine but after some time it stopped working for my mobile site and I could not explain why.
My main page is a category page which links to a page with all projects. It should scroll to the clicked project right away with a link like this: [https://benjaminmaier.it/portfolio/works/#mzw](link url)
I know there is a slash before the hashtag but it works for the desktop site. Tested on different mobile browsers and resized desktop browsers. The link just leads to the top of the page with all projects.
Anyone knows a solution?
Thanks and kind regards,
Ben -
Dear Ben @benjmaier
I ran into a similar problem here, which i thought was due to a .click() event not firing ( bottom of thread ):
But you have the same issue - it may be connected...
Will forward this and hopefully Armin can help us understand the change in Mobile :)Best wishes
Richard -
Hey please remove all custom javascript code related to anchorscrolling.
Since a while there's no custom code needed for this, it is built into laytheme.Meaning remove the javascript code that you posted here.
And make sure lay theme is up to date.
Now try again and see if it works. If not, let Richard know and then you can lemme know @Richard-K -
Hello Richard, @Richard-K
thanks for your answers. As Armin recommended I removed all the code, updated lay theme and then I put the code in again.
Sadly it still will not work. Without the js-code the anchors work but without the scrolling.Furthermore only the menu bar works in my main mobile browser, which would be opera. On other browsers the site works but the scroll does not.
Thanks
-
Dear @benjmaier
Regarding the Issue with Opera, since the last update many people are reporting this, and Armin is solving it as soon as he can, sorry if this has caused problems for you.
Regarding your anchor scroll question for Armin, have forwarded this, & will keep you updated!
Best wishes
Richard -
Dear @benjmaier
A new update has been released regarding the Firefox and Opera issues :)
Best
Richard -
hey @benjmaier
actually i have never tested lay theme for opera since it is not a widely used browser :|
does it work now?
-
Dear @Richard-K / @arminunruh ,
I updated Lay Theme and removed my custom code but unfortunately that didn’t do the trick.Smooth scrolling doesn’t work unless I add some js-code (or 'html{scroll-behavior: smooth;}' in the custom CSS).
And the menu doesn’t work at all on mobiles (unless I leave the phone layout as it is, without customising it, which unfortunately is not an option. I explained this behaviour in detail here)
Should you have any updates please let me know.
Thanks again,
Andrea -
Dear Andrea @and
Could you please send your website address, /wp-admin/ username and password and a link to this topic to info@laytheme.com?
And will try to get this sorted out as soon as possible :)Thank you for using Lay Andrea and sorry for any delay
Best
Richard
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it