From 0b070a8b069f160303dd87a7a33b264c2783eb76 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:11:50 +0100 Subject: [PATCH] the window scroller now supports iframes --- cypress/e2e/calcBordersDimensions-tests.cy.js | 2 +- .../e2e/calcScrollbarsDimensions-tests.cy.js | 4 +- .../e2e/calcXScrollbarDimension-tests.cy.js | 4 +- .../e2e/calcYScrollbarDimension-tests.cy.js | 4 +- cypress/e2e/getMaxScrollX-tests.cy.js | 8 +- cypress/e2e/getMaxScrollY-tests.cy.js | 8 +- cypress/e2e/getMaxScrolls-tests.cy.js | 16 +-- cypress/e2e/getWindowScroller-tests.cy.js | 6 +- src/main/common.js | 6 ++ src/main/uss.js | 102 ++++++++++-------- 10 files changed, 87 insertions(+), 73 deletions(-) diff --git a/cypress/e2e/calcBordersDimensions-tests.cy.js b/cypress/e2e/calcBordersDimensions-tests.cy.js index cfc8f88..de9afdf 100644 --- a/cypress/e2e/calcBordersDimensions-tests.cy.js +++ b/cypress/e2e/calcBordersDimensions-tests.cy.js @@ -19,7 +19,7 @@ describe("calcBordersDimensions", function() { const _windowBordersDimensions = uss.calcBordersDimensions(win, true); expect(constants.arraysAreEqual( _windowBordersDimensions, - uss.calcBordersDimensions(uss.getWindowScroller(true)) + uss.calcBordersDimensions(uss.getWindowScroller(win, true)) ) ).to.be.true; diff --git a/cypress/e2e/calcScrollbarsDimensions-tests.cy.js b/cypress/e2e/calcScrollbarsDimensions-tests.cy.js index 24f943a..6802daf 100644 --- a/cypress/e2e/calcScrollbarsDimensions-tests.cy.js +++ b/cypress/e2e/calcScrollbarsDimensions-tests.cy.js @@ -23,7 +23,7 @@ describe("calcScrollbarsDimensions", function() { const _windowScrollbarsDimensions = uss.calcScrollbarsDimensions(win, true); expect(constants.arraysAreEqual( _windowScrollbarsDimensions, - uss.calcScrollbarsDimensions(uss.getWindowScroller(true)) + uss.calcScrollbarsDimensions(uss.getWindowScroller(win, true)) ) ).to.be.true; @@ -74,7 +74,7 @@ describe("calcScrollbarsDimensions", function() { expect(constants.arraysAreEqual(uss.calcScrollbarsDimensions(_elementWithScrollbarOnTheXAxis), [_maxDim,0])).to.be.true; expect(constants.arraysAreEqual(uss.calcScrollbarsDimensions(_elementWithScrollbarOnTheYAxis), [0,_maxDim])).to.be.true; expect(constants.arraysAreEqual(uss.calcScrollbarsDimensions(_elementWithScrollbarOnTheXYAxes), [_maxDim,_maxDim])).to.be.true; - expect(constants.arraysAreEqual(uss.calcScrollbarsDimensions(uss.getWindowScroller()), + expect(constants.arraysAreEqual(uss.calcScrollbarsDimensions(uss.getWindowScroller(win)), uss.calcScrollbarsDimensions(win)) ).to.be.true; diff --git a/cypress/e2e/calcXScrollbarDimension-tests.cy.js b/cypress/e2e/calcXScrollbarDimension-tests.cy.js index ae75cc5..d847d95 100644 --- a/cypress/e2e/calcXScrollbarDimension-tests.cy.js +++ b/cypress/e2e/calcXScrollbarDimension-tests.cy.js @@ -21,7 +21,7 @@ describe("calcXScrollbarDimension", function() { //Test the window's x-scrollbar. const _windowXScrollbarDimension = uss.calcXScrollbarDimension(win, true); - expect(_windowXScrollbarDimension).to.equal(uss.calcXScrollbarDimension(uss.getWindowScroller(true))); + expect(_windowXScrollbarDimension).to.equal(uss.calcXScrollbarDimension(uss.getWindowScroller(win, true))); const _windowXScrollbarCachedDimension = uss._containersData.get(win)[constants.K_VSB]; expect(_windowXScrollbarDimension).to.equal(_windowXScrollbarCachedDimension); @@ -63,7 +63,7 @@ describe("calcXScrollbarDimension", function() { expect(uss.calcXScrollbarDimension(_elementWithScrollbarOnTheXAxis)).to.equal(_maxDim); expect(uss.calcXScrollbarDimension(_elementWithScrollbarOnTheYAxis)).to.equal(0); expect(uss.calcXScrollbarDimension(_elementWithScrollbarOnTheXYAxes)).to.equal(_maxDim); - expect(uss.calcXScrollbarDimension(uss.getWindowScroller())).to.equal(uss.calcXScrollbarDimension(win)); + expect(uss.calcXScrollbarDimension(uss.getWindowScroller(win))).to.equal(uss.calcXScrollbarDimension(win)); //Test if the scroll positions have changed due to the measuring (they should not). expect(constants.arraysAreEqual(_getCurrentScrollPos(win), _windowOriginalPos)).to.be.true; diff --git a/cypress/e2e/calcYScrollbarDimension-tests.cy.js b/cypress/e2e/calcYScrollbarDimension-tests.cy.js index 86ca9d2..10cddb5 100644 --- a/cypress/e2e/calcYScrollbarDimension-tests.cy.js +++ b/cypress/e2e/calcYScrollbarDimension-tests.cy.js @@ -21,7 +21,7 @@ describe("calcYScrollbarDimension", function() { //Test the window's y-scrollbar. const _windowYScrollbarDimension = uss.calcYScrollbarDimension(win, true); - expect(_windowYScrollbarDimension).to.equal(uss.calcYScrollbarDimension(uss.getWindowScroller(true))); + expect(_windowYScrollbarDimension).to.equal(uss.calcYScrollbarDimension(uss.getWindowScroller(win, true))); const _windowYScrollbarCachedDimension = uss._containersData.get(win)[constants.K_HSB]; expect(_windowYScrollbarDimension).to.equal(_windowYScrollbarCachedDimension); @@ -63,7 +63,7 @@ describe("calcYScrollbarDimension", function() { expect(uss.calcYScrollbarDimension(_elementWithScrollbarOnTheXAxis)).to.equal(0); expect(uss.calcYScrollbarDimension(_elementWithScrollbarOnTheYAxis)).to.equal(_maxDim); expect(uss.calcYScrollbarDimension(_elementWithScrollbarOnTheXYAxes)).to.equal(_maxDim); - expect(uss.calcYScrollbarDimension(uss.getWindowScroller())).to.equal(uss.calcYScrollbarDimension(win)); + expect(uss.calcYScrollbarDimension(uss.getWindowScroller(win))).to.equal(uss.calcYScrollbarDimension(win)); //Test if the scroll positions have changed due to the measuring (they should not). expect(constants.arraysAreEqual(_getCurrentScrollPos(win), _windowOriginalPos)).to.be.true; diff --git a/cypress/e2e/getMaxScrollX-tests.cy.js b/cypress/e2e/getMaxScrollX-tests.cy.js index 18b8f17..87414f6 100644 --- a/cypress/e2e/getMaxScrollX-tests.cy.js +++ b/cypress/e2e/getMaxScrollX-tests.cy.js @@ -24,8 +24,8 @@ describe("getMaxScrollX", function() { const _expectedMaxScrollX = 0.5 * _testElement.scrollWidth + uss.getScrollbarsMaxDimension(); //Test the Window - expect(uss.getMaxScrollX(win, false)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(), false)); - expect(uss.getMaxScrollX(win, true)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(), true)); + expect(uss.getMaxScrollX(win, false)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(win), false)); + expect(uss.getMaxScrollX(win, true)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(win), true)); expect(Number.isFinite(uss.getMaxScrollX(_testElement, true))).to.be.true; expect(Number.isFinite(uss.getMaxScrollX(_testElement, false))).to.be.true; @@ -47,8 +47,8 @@ describe("getMaxScrollX", function() { uss.stopScrolling(_testElement); uss.stopScrollingAll(); expect(uss.getMaxScrollX(_testElement, false)).to.be.closeTo(_expectedMaxScrollX, 1); - expect(uss.getMaxScrollX(win, false)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(), false)); - expect(uss.getMaxScrollX(win, true)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(), true)); + expect(uss.getMaxScrollX(win, false)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(win), false)); + expect(uss.getMaxScrollX(win, true)).to.equal(uss.getMaxScrollX(uss.getWindowScroller(win), true)); }); }); }); diff --git a/cypress/e2e/getMaxScrollY-tests.cy.js b/cypress/e2e/getMaxScrollY-tests.cy.js index a395a61..39e1932 100644 --- a/cypress/e2e/getMaxScrollY-tests.cy.js +++ b/cypress/e2e/getMaxScrollY-tests.cy.js @@ -24,8 +24,8 @@ describe("getMaxScrollY", function() { const _expectedMaxScrollY = 0.5 * _testElement.scrollHeight + uss.getScrollbarsMaxDimension(); //Test the Window - expect(uss.getMaxScrollY(win, false)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(), false)); - expect(uss.getMaxScrollY(win, true)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(), true)); + expect(uss.getMaxScrollY(win, false)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(win), false)); + expect(uss.getMaxScrollY(win, true)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(win), true)); expect(Number.isFinite(uss.getMaxScrollY(_testElement), true)).to.be.true; expect(Number.isFinite(uss.getMaxScrollY(_testElement), false)).to.be.true; @@ -47,8 +47,8 @@ describe("getMaxScrollY", function() { uss.stopScrolling(_testElement); uss.stopScrollingAll(); expect(uss.getMaxScrollY(_testElement, false)).to.be.closeTo(_expectedMaxScrollY, 1); - expect(uss.getMaxScrollY(win, false)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(), false)); - expect(uss.getMaxScrollY(win, true)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(), true)); + expect(uss.getMaxScrollY(win, false)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(win), false)); + expect(uss.getMaxScrollY(win, true)).to.equal(uss.getMaxScrollY(uss.getWindowScroller(win), true)); }); }); }); diff --git a/cypress/e2e/getMaxScrolls-tests.cy.js b/cypress/e2e/getMaxScrolls-tests.cy.js index 3f8e294..b119e55 100644 --- a/cypress/e2e/getMaxScrolls-tests.cy.js +++ b/cypress/e2e/getMaxScrolls-tests.cy.js @@ -25,10 +25,10 @@ describe("getMaxScrolls", function() { const _expectedMaxScrollY = 0.5 * _testElement.scrollHeight + uss.getScrollbarsMaxDimension(); //Test the Window - expect(uss.getMaxScrolls(win, false)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), false)[0]); - expect(uss.getMaxScrolls(win, false)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), false)[1]); - expect(uss.getMaxScrolls(win, true)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), true)[0]); - expect(uss.getMaxScrolls(win, true)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), true)[1]); + expect(uss.getMaxScrolls(win, false)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), false)[0]); + expect(uss.getMaxScrolls(win, false)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), false)[1]); + expect(uss.getMaxScrolls(win, true)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), true)[0]); + expect(uss.getMaxScrolls(win, true)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), true)[1]); expect(Number.isFinite(uss.getMaxScrolls(_testElement, true)[0])).to.be.true; expect(Number.isFinite(uss.getMaxScrolls(_testElement, true)[1])).to.be.true; @@ -63,10 +63,10 @@ describe("getMaxScrolls", function() { uss.stopScrollingAll(); expect(uss.getMaxScrolls(_testElement, false)[0]).to.be.closeTo(_expectedMaxScrollX, 1); expect(uss.getMaxScrolls(_testElement, false)[1]).to.be.closeTo(_expectedMaxScrollY, 1); - expect(uss.getMaxScrolls(win, false)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), false)[0]); - expect(uss.getMaxScrolls(win, false)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), false)[1]); - expect(uss.getMaxScrolls(win, true)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), true)[0]); - expect(uss.getMaxScrolls(win, true)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(), true)[1]); + expect(uss.getMaxScrolls(win, false)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), false)[0]); + expect(uss.getMaxScrolls(win, false)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), false)[1]); + expect(uss.getMaxScrolls(win, true)[0]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), true)[0]); + expect(uss.getMaxScrolls(win, true)[1]).to.equal(uss.getMaxScrolls(uss.getWindowScroller(win), true)[1]); }); }); }); diff --git a/cypress/e2e/getWindowScroller-tests.cy.js b/cypress/e2e/getWindowScroller-tests.cy.js index d13b5cb..b1163e7 100644 --- a/cypress/e2e/getWindowScroller-tests.cy.js +++ b/cypress/e2e/getWindowScroller-tests.cy.js @@ -25,11 +25,11 @@ describe("getWindowScroller", function() { win.scroll(100, 100); if(_htmlResetCorrectly && _hasSameCoordinatesAsWindow(_html)) { - expect(uss.getWindowScroller()).to.equal(_html); + expect(uss.getWindowScroller(win)).to.equal(_html); } else if(_bodyResetCorrectly && _hasSameCoordinatesAsWindow(_body)) { - expect(uss.getWindowScroller()).to.equal(_body); + expect(uss.getWindowScroller(win)).to.equal(_body); } else { - expect(uss.getWindowScroller()).to.equal(win); + expect(uss.getWindowScroller(win)).to.equal(win); } }); }); diff --git a/src/main/common.js b/src/main/common.js index b2822df..643af5f 100644 --- a/src/main/common.js +++ b/src/main/common.js @@ -182,6 +182,12 @@ export const K_MCBQ = 32; */ export const K_FGS = 33; +/** + * Key to get the element that scrolls a window (its window scroller). + */ +export const K_WDS = 34; + + /** diff --git a/src/main/uss.js b/src/main/uss.js index fc0718e..8d78b88 100644 --- a/src/main/uss.js +++ b/src/main/uss.js @@ -53,6 +53,7 @@ import { K_RCBQ, K_MCBQ, K_FGS, + K_WDS, NO_SP, NO_FGS, NO_VAL, @@ -103,6 +104,8 @@ const DEFAULT_LOG_OPTIONS = new Map([ ["getXStepLengthCalculator", { primaryMsg: "container" + DEFAULT_ERROR_PRIMARY_MSG_1 }], ["getYStepLengthCalculator", { primaryMsg: "container" + DEFAULT_ERROR_PRIMARY_MSG_1 }], + + ["getWindowScroller", { primaryMsg: "container" + DEFAULT_ERROR_PRIMARY_MSG_1 }], ["setXStepLengthCalculator", [ { primaryMsg: "newCalculator" + DEFAULT_ERROR_PRIMARY_MSG_3 }, @@ -631,12 +634,6 @@ export let _framesTime = DEFAULT_FRAME_TIME; */ export let _framesTimes = []; //TODO: perhaps const? -/** - * The container that scrolls the `window` when it's scrolled and - * that (viceversa) is scrolled when the `window` is scrolled. - */ -export let _windowScroller = NO_VAL; - /** * The container that scrolls the `document`. * It's also the value used when an API method requires the `container` input parameter but nothing is passed. @@ -1012,22 +1009,33 @@ export const getScrollbarsMaxDimension = (forceCalculation = false) => { } /** - * Returns the value of the `_windowScroller` property. + * Returns the value of the `window scroller` of the passed container. + * @param {*} [container] An instance of `Element` or a `window`. * @param {boolean} forceCalculation If `true` the value is calculated on the fly (expensive operation), otherwise it's returned from cache. - * @returns {*} The element that scrolls `window` when it's scrolled and that (viceversa) is scrolled when `window` is scrolled. + * @returns {*} The element that scrolls the `window` of `container` when it's scrolled and that (viceversa) is scrolled when that `window` is scrolled. */ //TODO: add a new parameter so that GET_WINDOW_OF(container) can be used instead of window -export const getWindowScroller = (forceCalculation = false) => { - if (forceCalculation || !_windowScroller) { - const _oldData = _containersData.get(window); - const _containerData = _oldData || []; - if (!_oldData) INIT_CONTAINER_DATA(window, _containerData); +export const getWindowScroller = (container = _pageScroller, forceCalculation = false) => { + let _oldData = _containersData.get(container); + let _containerData = _oldData || []; - const _body = document.body; - const _html = document.documentElement; + if (!_oldData && !INIT_CONTAINER_DATA(container, _containerData)) { + _errorLogger(CREATE_LOG_OPTIONS(options, "getWindowScroller", { secondaryMsg: container }, DEFAULT_LOG_OPTIONS)); + return; + } + + const _window = IS_WINDOW(container) ? container : GET_WINDOW_OF(container); + _oldData = _containersData.get(_window); + _containerData = _oldData || []; + + if (forceCalculation || _containerData[K_WDS] == NO_VAL) { + if (!_oldData) INIT_CONTAINER_DATA(_window, _containerData); + + const _body = _window.document.body; + const _html = _window.document.documentElement; - const _windowInitialX = window.scrollX; - const _windowInitialY = window.scrollY; + const _windowInitialX = _window.scrollX; + const _windowInitialY = _window.scrollY; const _elementsToTest = []; let _elementsIndex = 0; @@ -1047,10 +1055,10 @@ export const getWindowScroller = (forceCalculation = false) => { _elementsIndex++; } - //Neither _html nor _body have the same scrollPosition of window. + //Neither _html nor _body have the same scrollPosition of _window. if (_elementsIndex === 0) { - _windowScroller = window; - return _windowScroller; + _containerData[K_WDS] = _window; + return _window; } let _maxScrollX = _containerData[K_MSX] !== NO_VAL ? _containerData[K_MSX] : HIGHEST_SAFE_SCROLL_POS; @@ -1060,34 +1068,34 @@ export const getWindowScroller = (forceCalculation = false) => { (_maxScrollX > 0 && _windowInitialX !== _maxScrollX) || (_maxScrollY > 0 && _windowInitialY !== _maxScrollY) ) { - //Try scrolling the body/html by scrolling window. - window.scroll(HIGHEST_SAFE_SCROLL_POS, HIGHEST_SAFE_SCROLL_POS); + //Try scrolling the body/html by scrolling _window. + _window.scroll(HIGHEST_SAFE_SCROLL_POS, HIGHEST_SAFE_SCROLL_POS); - _maxScrollX = window.scrollX; - _maxScrollY = window.scrollY; + _maxScrollX = _window.scrollX; + _maxScrollY = _window.scrollY; //Cache the maxScrollX/maxScrollY. _containerData[K_MSX] = _maxScrollX; _containerData[K_MSY] = _maxScrollY; } - //window cannot scroll. + //_window cannot scroll. if (_maxScrollX === 0 && _maxScrollY === 0) { - _windowScroller = window; - return _windowScroller; + _containerData[K_WDS] = _window; + return _window; } - //window was already at its maxScrollX/maxScrollY. + //_window was already at its maxScrollX/maxScrollY. if (_windowInitialX === _maxScrollX && _windowInitialY === _maxScrollY) { - //Try scrolling the body/html by scrolling window. - window.scroll(0, 0); + //Try scrolling the body/html by scrolling _window. + _window.scroll(0, 0); } let _windowScrollerFound = false; for (const element of _elementsToTest) { if ( - window.scrollX === element.scrollLeft && - window.scrollY === element.scrollTop + _window.scrollX === element.scrollLeft && + _window.scrollY === element.scrollTop ) { //Cache the maxScrollX/maxScrollY. const _elementOldData = _containersData.get(element); @@ -1097,26 +1105,26 @@ export const getWindowScroller = (forceCalculation = false) => { if (!_elementOldData) INIT_CONTAINER_DATA(element, _elementData); - _windowScroller = element; + _containerData[K_WDS] = element; _windowScrollerFound = true; break; } } /** - * Scroll window back to its initial position. - * Note that if window scrolls any other element, + * Scroll _window back to its initial position. + * Note that if _window scrolls any other element, * the latter will be scrolled back into place too. * Otherwise it was already in the correct scroll position * because the tests didn't affect it. */ - window.scroll(_windowInitialX, _windowInitialY); + _window.scroll(_windowInitialX, _windowInitialY); - //Fallback to window. - if (!_windowScrollerFound) _windowScroller = window; + //Fallback to _window. + if (!_windowScrollerFound) _containerData[K_WDS] = _window; } - return _windowScroller; + return _containerData[K_WDS]; } /** @@ -1544,7 +1552,7 @@ export const calcScrollbarsDimensions = (container = _pageScroller, forceCalcula _containerData[K_VSB] === NO_VAL || _containerData[K_HSB] === NO_VAL ) { - const _windowScroller = getWindowScroller(); + const _windowScroller = getWindowScroller(container); if (IS_WINDOW(container) && container !== _windowScroller) { return calcScrollbarsDimensions( @@ -1642,7 +1650,7 @@ export const calcBordersDimensions = (container = _pageScroller, forceCalculatio _containerData[K_LB] === NO_VAL ) { if (IS_WINDOW(container)) { - const _windowScroller = getWindowScroller(); + const _windowScroller = getWindowScroller(container); const _bordersDimensions = IS_WINDOW(_windowScroller) ? [0, 0, 0, 0] : calcBordersDimensions(_windowScroller, forceCalculation, options); @@ -1775,7 +1783,7 @@ export const getMaxScrolls = (container = _pageScroller, forceCalculation = fals //Scroll the container back to its initial position. container.scroll(_initialXPosition, _initialYPosition); - let _windowScroller = getWindowScroller(); + let _windowScroller = getWindowScroller(container); /** * This is a summary table of the output: @@ -1882,7 +1890,7 @@ export const getXScrollableParent = (container = _pageScroller, includeHiddenPar } const _containerInitialX = container.getBoundingClientRect().left; - const _windowScroller = getWindowScroller(); + const _windowScroller = getWindowScroller(container); let _parent = container.parentElement; const _isScrollableParent = (overflowRegex) => { @@ -2001,7 +2009,7 @@ export const getYScrollableParent = (container = _pageScroller, includeHiddenPar } const _containerInitialY = container.getBoundingClientRect().top; - const _windowScroller = getWindowScroller(); + const _windowScroller = getWindowScroller(container); let _parent = container.parentElement; const _isScrollableParent = (overflowRegex) => { @@ -2158,7 +2166,7 @@ export const getScrollableParent = (container = _pageScroller, includeHiddenPare const _containerInitialPos = container.getBoundingClientRect(); const _containerInitialX = _containerInitialPos.left; const _containerInitialY = _containerInitialPos.top; - const _windowScroller = getWindowScroller(); + const _windowScroller = getWindowScroller(container); let _parent = container.parentElement; const _isScrollableParent = (overflowRegex) => { @@ -3351,8 +3359,8 @@ const ussInit = () => { //Calculate the _scrollbarsMaxDimension. getScrollbarsMaxDimension(); - //Calculate the _windowScroller. - getWindowScroller(); + //Calculate the window scroller of THIS_WINDOW. + getWindowScroller(THIS_WINDOW); //Calculate the _pageScroller. getPageScroller();