Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Remove dom-helpers dependency
- Loading branch information
1 parent
bdb4baa
commit 8380212
Showing
10 changed files
with
72 additions
and
45 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
import isWindow from 'dom-helpers/query/isWindow'; | ||
import ownerDocument from '../utils/ownerDocument'; | ||
import ownerWindow from '../utils/ownerWindow'; | ||
|
||
export function isBody(node) { | ||
return node && node.tagName.toLowerCase() === 'body'; | ||
} | ||
|
||
// Do we have a vertical scroll bar? | ||
// Do we have a vertical scrollbar? | ||
export default function isOverflowing(container) { | ||
const doc = ownerDocument(container); | ||
const win = ownerWindow(doc); | ||
|
||
/* istanbul ignore next */ | ||
if (!isWindow(doc) && !isBody(container)) { | ||
return container.scrollHeight > container.clientHeight; | ||
if (doc.body === container) { | ||
return win.innerWidth > doc.documentElement.clientWidth; | ||
} | ||
|
||
// Takes in account potential non zero margin on the body. | ||
const style = win.getComputedStyle(doc.body); | ||
const marginLeft = parseInt(style.getPropertyValue('margin-left'), 10); | ||
const marginRight = parseInt(style.getPropertyValue('margin-right'), 10); | ||
|
||
return marginLeft + doc.body.clientWidth + marginRight < win.innerWidth; | ||
return container.scrollHeight > container.clientHeight; | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// A change of the browser zoom change the scrollbar size. | ||
function getScrollbarSize() { | ||
const scrollDiv = document.createElement('div'); | ||
scrollDiv.style.width = '99px'; | ||
scrollDiv.style.height = '99px'; | ||
scrollDiv.style.position = 'absolute'; | ||
scrollDiv.style.top = '-9999px'; | ||
scrollDiv.style.overflow = 'scroll'; | ||
|
||
document.body.appendChild(scrollDiv); | ||
const scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; | ||
document.body.removeChild(scrollDiv); | ||
|
||
return scrollbarSize; | ||
} | ||
|
||
export default getScrollbarSize; |