Last active
December 9, 2016 08:00
-
-
Save ksk1015/4728c3d44c0d93740fdd55180d1f24d5 to your computer and use it in GitHub Desktop.
window.scrollMaxX, window.scrollMaxY polyfill, add scrollMaxX, scrollMaxY to HTMLElement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// window.scrollMaxX, window.scrollMaxY polyfill | |
'scrollMaxX' in window || Object.defineProperties(window, { | |
scrollMaxX: { | |
enumerable: true, | |
get: function(){ | |
return document.documentElement.scrollWidth - document.documentElement.clientWidth; | |
}, | |
}, | |
scrollMaxY: { | |
enumerable: true, | |
get: function(){ | |
return document.documentElement.scrollHeight - document.documentElement.clientHeight; | |
}, | |
} | |
}); | |
// add scrollMaxX, scrollMaxY to HTMLElement | |
'scrollMaxX' in HTMLElement || Object.defineProperties(HTMLElement.prototype, { | |
scrollMaxX: { | |
enumerable: true, | |
get: function(){ | |
return this.scrollWidth - this.clientWidth; | |
}, | |
}, | |
scrollMaxY: { | |
enumerable: true, | |
get: function(){ | |
return this.scrollHeight - this.clientHeight; | |
}, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo
http://jsdo.it/ksk1015/ElDs