diff --git a/src/htmx.js b/src/htmx.js index f5e68da9..152d95cd 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -57,6 +57,8 @@ return (function () { return "[hx-" + verb + "], [data-hx-" + verb + "]" }).join(", "); + var windowIsScrolling = false // used by initScrollHandler + //==================================================================== // Utilities //==================================================================== @@ -765,13 +767,20 @@ return (function () { function initScrollHandler() { if (!window['htmxScrollHandler']) { var scrollHandler = function() { - forEach(getDocument().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"), function (elt) { - maybeReveal(elt); - }); + windowIsScrolling = true }; window['htmxScrollHandler'] = scrollHandler; window.addEventListener("scroll", scrollHandler) } + + setInterval(function() { + if (windowIsScrolling) { + windowIsScrolling = false; + forEach(getDocument().querySelectorAll("[hx-trigger='revealed'],[data-hx-trigger='revealed']"), function (elt) { + maybeReveal(elt); + }) + } + }, 200); } function maybeReveal(elt) { diff --git a/test/index.html b/test/index.html index 06102a59..dfca4a26 100644 --- a/test/index.html +++ b/test/index.html @@ -37,7 +37,10 @@ Confirm & Prompt Test
  • - Scroll Test + Scroll Test 1 - Start/End +
  • +
  • + Scroll Test 2 - Event Handler
  • diff --git a/test/manual/scroll-test-eventHandler.html b/test/manual/scroll-test-eventHandler.html new file mode 100644 index 00000000..9930d97c --- /dev/null +++ b/test/manual/scroll-test-eventHandler.html @@ -0,0 +1,107 @@ + + + + Test Scroll Event Handler + + + + + + + + + + +

    Scrolling Event Handler Tests

    +

    You should be able to scroll this page at any speed and see HTML fragments loaded into the DIVs "remotely" without any hiccups.

    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + diff --git a/test/manual/scroll-tests.html b/test/manual/scroll-test-startEnd.html similarity index 95% rename from test/manual/scroll-tests.html rename to test/manual/scroll-test-startEnd.html index 8e47bbd6..43b69c33 100644 --- a/test/manual/scroll-tests.html +++ b/test/manual/scroll-test-startEnd.html @@ -13,7 +13,7 @@ server.autoRespond = true; server.respondWith("GET", "/more_divs", "
    More Content
    "); -

    Prompt & Confirm Tests

    +

    Scrolling Start/End Tests

    End