diff --git a/src/AffixMixin.js b/src/AffixMixin.js index b911bad4f4..af97e131c7 100644 --- a/src/AffixMixin.js +++ b/src/AffixMixin.js @@ -38,7 +38,7 @@ const AffixMixin = { } DOMNode = React.findDOMNode(this); - scrollHeight = document.documentElement.offsetHeight; + scrollHeight = domUtils.getDocumentHeight(); scrollTop = window.pageYOffset; position = domUtils.getOffset(DOMNode); diff --git a/src/utils/domUtils.js b/src/utils/domUtils.js index 256aaf64f8..f0df13f8cf 100644 --- a/src/utils/domUtils.js +++ b/src/utils/domUtils.js @@ -78,6 +78,15 @@ function getOffset(DOMNode) { }; } +/** + * Get the height of the document + * + * @returns {documentHeight: number} + */ +function getDocumentHeight() { + return Math.max(document.documentElement.offsetHeight, document.height, document.body.scrollHeight, document.body.offsetHeight); +} + /** * Get elements position * @@ -205,6 +214,7 @@ export default { ownerDocument, getComputedStyles, getOffset, + getDocumentHeight, getPosition, getSize, activeElement: getActiveElement,