• Halil ESEN

    (@halilesen)


    Hi Ben, I hope you are well. I used code * { scroll-behavior: smooth; } for some links. But this was a problem for scroll-to-top. When clicked, it waits for a while and then accelerates. It moves slowly at first and then returns to normal. I think it does with js what can be done with css. Is there a way to override scrolling js scripts?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Hey there,

    I think the best idea would be to make your CSS more specific. The scroll-to-top arrow is in the footer, so you could target all links inside the main content area like this without affecting it:

    .main a { 
      scroll-behavior: smooth; 
    }

    That will affect all links besides ones in the header and footer.

    Thread Starter Halil ESEN

    (@halilesen)

    Okey, but where should I look to remove its JS codes?

    Theme Author Ben Sibley

    (@bensibley)

    You’ll need to dequeue the Javascript file, like this:

    function my_dequeue_script() {
      wp_dequeue_script( 'ct-mission-news-js');
    }
    add_action( 'wp_enqueue_scripts', 'my_dequeue_script' );
    

    Then you can copy all of the JS from the production.js file in Mission News into a JS file in your own child theme and enqueue that JS file. You can remove the bit of code at the bottom that handles the scroll-to-top arrow.

    Thread Starter Halil ESEN

    (@halilesen)

    Before that, I tried to delete the code from js/build/production.js and js/build/production.min.js files in the main theme, or rather delete the postponement part, but it did not work.

    Theme Author Ben Sibley

    (@bensibley)

    Deleting that code from production.min.js would work as long as you clear the cache afterwards so the new version of the file gets loaded. However, this change would be overridden every time Mission News updates, so you’d have to do this repeatedly. That’s why it’s better to make a change in the child theme instead.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘breaking JS for scroll-to-top’ is closed to new replies.