0

I want to add smooth scroll along the effect like this codepen shows :- https://codepen.io/jrsouth/pen/xPybjd, but if I copy this same codepen and add locomotive-scroll to it, it just looks like a normal html document and no effect is seen.

I want to finally make a scmmoth-scroll effect and the effect which is present in the codepen. You can take this website as refernence https://cuberto.com/

1 Answers1

0

You can set the screen position from DOM window.scroll() ; You can increment the screen position from top value value. First make sure to have a long html page to be able to notice the scrolling effect.

function go(vs)
{
  vs=vs+ 5; //Let's say steps of 5
  window.scroll({top: vs, left:0, behavior: 'smooth'});
  let sto= setTimeout(go,20,vs);
//Did you notice the arguments order? function, millisecs, parameter

//It's better to set a stop scenario
  document.querySelector("html").onclick=
  function(){clearTimeout(sto);  bin=0;}; 

}
go(0); // Call the function from 0
  • I'm using this SmoothScroll function `https://github.com/codebucks27/react-smooth-scroll/blob/main/src/components/SmoothScroll.js` , due to SmoothScroll function which I'm using, still I'm not able to achieve the effect in the codepen along with smooth scrolling. The function you provided is automatically scrolling the page. – Harshvardhan Shete Apr 25 '23 at 06:54
  • In the last line I launched the function but you can set a event instead. Why not create a button ? `` – Axonile Plus Apr 28 '23 at 18:46