| 1 |
import isIE from './isIE'; |
| 2 |
|
| 3 |
function getSize(axis, body, html, computedStyle) { |
| 4 |
return Math.max( |
| 5 |
body[`offset${axis}`], |
| 6 |
body[`scroll${axis}`], |
| 7 |
html[`client${axis}`], |
| 8 |
html[`offset${axis}`], |
| 9 |
html[`scroll${axis}`], |
| 10 |
isIE(10) |
| 11 |
? (parseInt(html[`offset${axis}`]) + |
| 12 |
parseInt(computedStyle[`margin${axis === 'Height' ? 'Top' : 'Left'}`]) + |
| 13 |
parseInt(computedStyle[`margin${axis === 'Height' ? 'Bottom' : 'Right'}`])) |
| 14 |
: 0 |
| 15 |
); |
| 16 |
} |
| 17 |
|
| 18 |
export default function getWindowSizes(document) { |
| 19 |
const body = document.body; |
| 20 |
const html = document.documentElement; |
| 21 |
const computedStyle = isIE(10) && getComputedStyle(html); |
| 22 |
|
| 23 |
return { |
| 24 |
height: getSize('Height', body, html, computedStyle), |
| 25 |
width: getSize('Width', body, html, computedStyle), |
| 26 |
}; |
| 27 |
} |