I have the following code that based on scroll should set the active document, but currently the loop in checkScrollPosition i