• If you notice that the “scroll to top” speed is sluggish, review your SimpleTOC block and ensure that you deactivate “Smooth scrolling support” to eliminate the speed issue.

Viewing 1 replies (of 1 total)
  • Plugin Author Marc Toensing

    (@marcdk)

    Hi and thank you for bringing this to my attention. SimpleTOC just adds this css code:

    html {
     scroll-behavior: smooth;
    }

    while GeneratePress uses JavaScript like this one:

    ! function() {
    "use strict";
    var c;
    "querySelector" in document && "addEventListener" in window && (c = document.querySelector(".generate-back-to-top"), c) && (window.addEventListener("scroll", function() {
    var e = window.pageYOffset,
    t = c.getAttribute("data-start-scroll");
    t < e && c.classList.add("generate-back-to-top__show"), e < t && c.classList.remove("generate-back-to-top__show")
    }), c.addEventListener("click", function(e) {
    var t, o, n, a, r;
    e.preventDefault(), generatepressBackToTop.smooth ? (document.body, e = c.getAttribute("data-scroll-speed") || 400, t = window.pageYOffset, o = document.body.offsetTop, n = (o - t) / (e / 16), a = function() {
    window.pageYOffset <= (o || 0) && (clearInterval(r), document.activeElement.blur())
    }, r = setInterval(function() {
    window.scrollBy(0, n), a()
    }, 16)) : window.scrollTo(0, 0)
    }, !1))
    }();

    I don’t say that a JavaScript approach is worse or better than the native CSS solution. THe downside of CSS Is that it works in modern browsers only while the JS solution will work everytime. I don’t see any solution to use both. If you could add a “back to top” button without the Javascript and enable the SimpleTOC smooth scroll option, it would work, too. Because the css code applies to all elements. If someone is more clever than me and sees a solution please speak up. I love PR on GitHub. =)

    Meanwhile you could disable “back to top” in GeneratePress in Settings->Layout->Footer->Back top Top

Viewing 1 replies (of 1 total)
  • The topic ‘FIX — GeneratePress + Scroll to Top Slow Speed’ is closed to new replies.