You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
472 B
18 lines
472 B
'use strict'; |
|
|
|
var invariant = require('invariant'); |
|
var canUseDOM = require('can-use-dom'); |
|
|
|
/** |
|
* Returns the current scroll position of the window as { x, y }. |
|
*/ |
|
function getWindowScrollPosition() { |
|
invariant(canUseDOM, 'Cannot get current scroll position without a DOM'); |
|
|
|
return { |
|
x: window.pageXOffset || document.documentElement.scrollLeft, |
|
y: window.pageYOffset || document.documentElement.scrollTop |
|
}; |
|
} |
|
|
|
module.exports = getWindowScrollPosition; |