src/modules/inactive/rangy-position.js
function getScrollPosition(win) {
        var x = 0, y = 0;
        if (typeof win.pageXOffset == NUMBER && typeof win.pageYOffset == NUMBER) {
            x = win.pageXOffset;
            y = win.pageYOffset;
        } else {
            var doc = win.document;
            var docEl = doc.documentElement;
            var compatMode = doc.compatMode;
            var scrollEl = (typeof compatMode == "string" && compatMode.indexOf("CSS") >= 0 && docEl)
                ? docEl : dom.getBody(doc);

            if (scrollEl && typeof scrollEl.scrollLeft == NUMBER && typeof scrollEl.scrollTop == NUMBER) {
                try {
                    x = scrollEl.scrollLeft;
                    y = scrollEl.scrollTop;
                } catch (ex) {}
            }
        }
        return { x: x, y: y };
    }
function getScrollPosition(win) {
        var x = 0, y = 0;
        if (typeof win.pageXOffset == NUMBER && typeof win.pageYOffset == NUMBER) {
            x = win.pageXOffset;
            y = win.pageYOffset;
        } else {
            var doc = win.document;
            var docEl = doc.documentElement;
            var compatMode = doc.compatMode;
            var scrollEl = (typeof compatMode == "string" && compatMode.indexOf("CSS") >= 0 && docEl)
                ? docEl : dom.getBody(doc);

            if (scrollEl && typeof scrollEl.scrollLeft == NUMBER && typeof scrollEl.scrollTop == NUMBER) {
                try {
                    x = scrollEl.scrollLeft;
                    y = scrollEl.scrollTop;
                } catch (ex) {}
            }
        }
        return { x: x, y: y };
    }
function getScrollPosition ( win ) { var x = 0 , y = 0 ; if ( typeof win . pageXOffset == NUMBER && typeof win . pageYOffset == NUMBER ) { x = win . pageXOffset ; y = win . pageYOffset ; } else { var doc = win . document ; var docEl = doc . documentElement ; var compatMode = doc . compatMode ; var scrollEl = ( typeof compatMode == "string" && compatMode . indexOf ( "CSS" ) >= 0 && docEl ) ? docEl : dom . getBody ( doc ) ; if ( scrollEl && typeof scrollEl . scrollLeft == NUMBER && typeof scrollEl . scrollTop == NUMBER ) { try { x = scrollEl . scrollLeft ; y = scrollEl . scrollTop ; } catch ( ex ) { } } } return { x : x , y : y } ; }
Since Rangy can deal with multiple documents which could be in different modes, we have to do the checks every time, unless we cache a getScrollPosition function in each document. This would necessarily pollute the document's global namespace, which I'm choosing to view as a greater evil than a slight performance hit.
Since Rangy can deal with multiple documents which could be in different modes we have to do the checks every time unless we cache a getScrollPosition function in each document . This would necessarily pollute the document s global namespace which I m choosing to view as a greater evil than a slight performance hit .