jQuery-ScrollAppear icon indicating copy to clipboard operation
jQuery-ScrollAppear copied to clipboard

ScrollAppear don't work in IE8

Open ModuLIZER opened this issue 12 years ago • 1 comments

The reason for this is that window.innerWidth/innerHeight and window.pageXOffset/pageYOffset is not reconized.

This could be fixed by adding these two functions:

findSize: function () {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return {
        x: myWidth,
        y: myHeight};
},
getScrollOffsets: function() {
    // This works for all browsers except IE versions 8 and before
    if ( window.pageXOffset != null ) 
       return {
           x: window.pageXOffset, 
           y: window.pageYOffset
       };
    // For browsers in Standards mode
    var doc = window.document;
    if ( document.compatMode === "CSS1Compat" ) {
        return {
            x: doc.documentElement.scrollLeft, 
            y: doc.documentElement.scrollTop
        };
    }
    // For browsers in Quirks mode
    return { 
        x: doc.body.scrollLeft, 
        y: doc.body.scrollTop 
    }; 
},

And change the GetElementPosition function:

GetElementPosition : function () {
    this.top = action.settings.t.offset().top - action.settings.PixelOffset;
    this.left = action.settings.t.offset().left;
    this.width =  action.settings.t.width();
    this.height = action.settings.t.height();
    return (
        this.top >= action.getScrollOffsets().y &&
            this.left >= action.getScrollOffsets().x &&
            ((this.top + this.height)) <= (action.getScrollOffsets().y + action.findSize().y) &&
            (this.left + this.width) <= (action.getScrollOffsets().x + action.findSize().x)
        );
},

ModuLIZER avatar Apr 28 '14 11:04 ModuLIZER

Hey Morten,

Thanks for pointing this out. I hadn't really considered backwards compatibility when building this plugin for browsers that didn't support window.innerWidth / window.innerHeight or window.pageXOffset / window.pageYOffset.

I've pushed a simplified version of your request into the build (Version 1.0.4) and tested it on IE7 + IE8 with the success (I don't have IE4, nor will I support it).

Thanks again for bringing this to my attention :)

Cheers Dom

domsammut avatar Apr 29 '14 11:04 domsammut