Jump to content
Search Community

scrollTo different pages

Alexandra Spalato test
Moderator Tag

Recommended Posts

Hello, I'm working on this project (gatsbyjs) https://cadell.netlify.app/

all links are scroll links
there are only 2 pages, the home and the more
so when I'm on home I need to access the more submenus and when I'm on more I need to access the other top links which are scrolling links from the home page
I use this npm module for that https://www.npmjs.com/package/react-anchor-link-smooth-scroll

but it doesn't work for this case

would the scrollTo plugin work in this case ?

 

Link to comment
Share on other sites

Actually I tried and it doesn't

this is the website, here I use the native scroll, with scroll-behaviour: smooth, but it doesn't work in safari

as you can see as there is to pages my urls are like that: '/#someId' when it's home page, or 'more/#someId' when it's more page, and this doesn't work with scrollTo plugin

how can I do that ?

Link to comment
Share on other sites

 

Hey @Alexandra Spalato,

 


The different uses of href seem to irritate you.
Better you only use it for

  • an absolute URL - points to another web site (like href = "http://www.example.com/default.htm")
  • a relative URL - points to a file within a web site (like href = "default.htm")

Maybe this example will help you.

 

See the Pen rNxwpOm by mikeK (@mikeK) on CodePen

 

Happy scrolling ...

Mikel

  • Like 1
Link to comment
Share on other sites

Hi @mikel,

Thank you but I don't really understand the sense of your demo...

what I need is to scroll between pages, https://cadell.netlify.app/

here I use the native behaviour with scroll-behaviour: smooth

which doesn't work on safari, which is why I wanted to use something else

but here the url are for example on the more page 'more/#artists'

so if you are on the home page and click in the more submenu artists, it goes to the artist page and scroll to the section

then if I'm on the more page and click on the top menu which is the sections of the home page it changes pages and goes to the section, as I put the url like that '/#sellingAdvice'

They are all relative urls

and this is what I have reproduced in the codesandbox demo

but this type of url seems not to work with the scrollTo plugin, this is what I mean

let me know if you have a solution

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...