1

I have searched all over the place, and I am trying to create a function which will run when an event is received, except when the div is scrolled horizontally all the way to the end (to the right).

This is my current function:

document.addEventListener("event-fetch", function() {

    $.fn.hasHorizontalScrollBar = function () {
        return this[0].clientWidth < this[0].scrollWidth;
    }

    var datafetchdiv = $('#datafetch');

    if (datafetchdiv.hasHorizontalScrollBar()) {
        $(rightPaddle).removeClass('hidden');
    }
    else {
        $(rightPaddle).addClass('hidden');
    }

});

And this is the part I want to add another check to:

if (datafetchdiv.hasHorizontalScrollBar()) {
    $(rightPaddle).removeClass('hidden');
}

This should not run if the div is scrolled all the way to the right. I haven't managed to figure this out.

joq3
  • 145
  • 7
  • 1
    Possible duplicate of [How to detect the end of a horizontal scroll in a div?](https://stackoverflow.com/questions/32068664/how-to-detect-the-end-of-a-horizontal-scroll-in-a-div) – Vishnu Baliga Dec 05 '18 at 10:47

0 Answers0