How to anchor-to-another-page in phone version
-
Dear Lay-Theme-Team,
we have perfectly working anchors on our desktop version following your advice from the forum:
<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 - 170 },
{ duration: 1200 });
}
}
});
</script>What do we have to do to make them work in the phone version, too?
There the text-link directs to the right page but opens always on the top.
It worked when we turned the phone version off.
So we guess there's a way to get there but we just have no clue.
We are not into JS at all (but we love your theme and created a wonderful
page that's almost ready to launch) so I hope you have any advice for us
on that topic.Thank you very much for your support!
Best, Ivonne -
Dear @ivonnefehn
thank you!
Did you give the IDs also to the elements in the custom phone layout?
Best!
Marius -
Dear Marius,
yes, I just double-checked, I did give them the ID.
And the links in the text of the mobile version are there, too.So from your question I guess it should work without doing anything else?
Best, Ivonne -
Dear Marius,
I rebuilt it on an old test-page and this is my experience:
1
It worked in the custom phone layout, too.
That was with an older version of LAY.
After I updated the theme it doesn't work anymore, it starts at the top of the page.2
It still works when I turn the custom phone layout off (breakpoint 0).3
And I wonder:
In case it worked on mobile, too:
How does the phone layout know what „top“ is?
Because for the desktop version I entered in the „head CSS“ to start at top - 190 (the size of my menu bar):
{ scrollTop: jQuery(id).offset().top-190 },
In the mobile menu my menu bar is 40 – so top here would be different.
Or is that something the mobile version does automatically?I hope this is understandable ...
Thanks a lot for your help.
Best, Ivonne -
Dear @ivonnefehn
Can you post a link to your website?
We will then have a look and inspect that!
Many wishes!
Marius -
This post is deleted!
-
DEAR @ivonnefehn
NEVER NEVER NEVER POST A LOGIN TO WORDPRESS HERE.
SEND A PM!I deleted your post.
You need to uncheck "open link on new page" - then it works.
Best!
Marius
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login