Last active
December 7, 2015 15:42
-
-
Save brianswisher/b86c831559a0cae4a92e to your computer and use it in GitHub Desktop.
Get scroll right; return number
This file contains hidden or 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
(()=>{ | |
function getScrollAmount(){ | |
const doc = document.documentElement; | |
return { | |
left: (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0), | |
top: (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0) | |
}; | |
} | |
function getScrollMax(){ | |
const scrollAmount = getScrollAmount(); | |
return { | |
right: window.innerWidth + scrollAmount.left, | |
bottom: window.innerHeight + getScrollAmount().top | |
}; | |
} | |
function getScrollRight(){ | |
return getScrollMax().right; | |
} | |
return getScrollRight(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment