locomotive-scroll icon indicating copy to clipboard operation
locomotive-scroll copied to clipboard

Can't scroll back up when anchor links are clicked

Open smallio opened this issue 3 years ago • 11 comments

Hi guys working on a website for a client so quite urgent.

Everything is working perfectly aside from being able to scroll back up once an anchor link is clicked.

Any ideas what's going on / how to solve this?

Site is here: https://braingaintest.webflow.io/

Cheers!

smallio avatar May 09 '21 10:05 smallio

Hi I have the sam issue, how did you solve it? Thanks:)

filipdahl avatar May 18 '21 14:05 filipdahl

Same here

DonSeve avatar May 28 '21 05:05 DonSeve

Make sure your all sections are Loaded with image

$(window).on("load", function() {
   locoScroll.update();
});

Solved my Issue

thevectorbox avatar Jul 01 '21 12:07 thevectorbox

@Shikarikashikari ca n you explain please?

jeydi243 avatar Jul 09 '21 08:07 jeydi243

@Shikarikashikari ca n you explain please?

Yes is how I do it

const locoScroll = new LocomotiveScroll({
    el: document.querySelector(".locomotive-scroll"),
    smooth: true,
    multiplier: 1.0,
    class: 'in-view',
    reloadOnContextChange: true,
    smartphone: {
        smooth: false
    },
    tablet: {
        smooth: false
    },
	  smoothMobile: 0,
});

$(window).on("load", function() {
   locoScroll.update();
});

All you need to do is update the locoscroll after the window is loaded, so with that, locoscroll can calculate the image height

thevectorbox avatar Jul 13 '21 08:07 thevectorbox

Hmm doesn't work for me - anybody found any other solutions?

jamesla avatar Dec 14 '21 21:12 jamesla

Hey guys, try the snippet I shared here 👉 https://github.com/locomotivemtl/locomotive-scroll/issues/175#issuecomment-1082541029

mykt0ngc0 avatar Mar 30 '22 02:03 mykt0ngc0

Hey guys, try the snippet I shared here 👉 #175 (comment)

How can I apply this in WebFlow, where I don't have access to the Locomotive code (I'm using a copy-paste that goes in the body section in the site settings)? I'm also having problems with the anchor link going too far because Locomotive is confusing it, but can't use this workaround (https://www.youtube.com/watch?v=dG2uumcwX7s) as WebFlow doesn't allow "#" or "|" in the attributes section.

Thanks!

menachemspielman avatar Jun 01 '22 12:06 menachemspielman

@menachemspielman Just wrap the snippet with script tags like this:

<script>
/* Your Locomotive anchor scroll snippet here */
</script>

...then paste it to the "Before

tag" section under Custom code.

You can read it here: https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags#before-the-%3C/body%3E-tag

mykt0ngc0 avatar Jun 01 '22 12:06 mykt0ngc0

@menachemspielman Just wrap the snippet with script tags like this:

<script>
/* Your Locomotive anchor scroll snippet here */
</script>

...then paste it to the "Before tag" section under Custom code.

You can read it here: https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags#before-the-%3C/body%3E-tag

Thank you so much, that worked perfectly!

menachemspielman avatar Jun 01 '22 13:06 menachemspielman

@menachemspielman Just wrap the snippet with script tags like this:

<script>
/* Your Locomotive anchor scroll snippet here */
</script>

...then paste it to the "Before tag" section under Custom code.

You can read it here: https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags#before-the-%3C/body%3E-tag

Two more questions, if that's okay:

  1. Could something be interfering with my 'back to top' button? All my other navigation is working fine, but can't get that one to work...

  2. I'm trying to get the background to change when scrolling. I understand this may not be compatible with Locomotive. Is there any workaround that can make it work as it does in preview mode currently?

https://preview.webflow.com/preview/mspielman-com?utm_medium=preview_link&utm_source=designer&utm_content=mspielman-com&preview=0992bc7a66465b90ef14b23b15a4cbd2&workflow=preview

Thank you again! This is my first WebFlow site, and I really appreciate the help.

menachemspielman avatar Jun 01 '22 13:06 menachemspielman