href anchor and data-scrollto problem

1 reply · opened Mar 5, 2024

EelodjuhaszMar 5, 2024

I am using data-scrollto for inside page navigation:

 
[Go to Block
...
 ... 

When it is used on the same page it works perfectly.

But, when I am using the following code in index.html:

 
Go to Block at Devices html](#)

With the code above in index.html it

  1. opens devices.html instantly at the anchor for like .3s
  2. then jumps to the top
  3. and then scrolls back to the anchor

I have alerady added the following code to the index page to smooth it a little bit:

 
        jQuery(document).ready( function(){
            setTimeout(function() {
                if (location.hash) {
                    window.scrollTo(0, 0);
                }
            }, 1);
        });
    

With this at least it jumps to the top when loading not back and forth.

Scrolling would not be too bad if it scrolled instantly, but it takes almost 2sec to start the scrolldown animation when opened from an external link which is way too much.

So to sum up, I want to use scrolling when staying on the same page (using data-scrollto), but when opened from an external page (using href anchor) I just want to jump to the anchor.

OR

Somehow make the scrolling animation to start faster when the href anchor link is clicked from an external page.

I tried to find the solution for both in functions.js but I was not successful.

Could you please help me?

Thank you in advance

EelodjuhaszMar 6, 2024

I managed to solve this by using custom code for scrolling and not using data-scrollto.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard