Auto Scroll - Automatically add content as the user scrolls the mouse wheel

A jquery object is a bit like an array of javascript dom nodes
so iterating over the jquery object will give you dom nodes

You could replace the methods that are working on jquery objects

    def max_scroll_top(self, jq_object):
        return max(jq_object.slice(n).scrollTop() for n in range(len(jq_object)))

with methods that work on the javascript dom nodes instead

    def max_scroll_top(self, jq_object):
        return max(dom_node.scrollTop for dom_node in jq_object)

And then since jq_object is always self.jq_elements_with_scrollbar
you could just remove the second argument to the function

note:
jquery_object.height() -> dom_node.clientHeight

1 Like