Link to a section on another page not working with Luxy.js smooth scroll - Any workarounds?

I said it all in the title :slight_smile:
I have a link that needs to direct to a section on another page. I also have a script running for a smooth scroll (Luxy.js from Flowbase). When I remove the script it works, and with the script it doesn’t, it just links to the top of the page. Any ideas on how to work around this, if even possible?

edit: just to mention that link to a section on the same page, with the script, works.

Cheers

Hi @Darko_Markovic

We have faced absolutely the same issue.

The small workaround made it work. Not Sure this is the best approach, but quite fine for one pager.

On the target page, where we need to scroll to a specific section on the Custom Code section we placed a small script:


<script>

window.onload= function() {

  var urlHash = window.location.hash;
if (urlHash)
	{
  $('html, body').animate({
         scrollTop: $("" + urlHash).offset().top
   }, 500);
  event.preventDefault();
	}
}
</script>

Once page loaded it checks if the hash exist in the URL and forcibly scrolls to this section.
Not as smooths as Luxy, especially if target section is footer and page long, but it does the job.

Let me know if this helps.

Cheers!