aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fbjs/lib/getUnboundedScrollPosition.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/fbjs/lib/getUnboundedScrollPosition.js')
-rw-r--r--node_modules/fbjs/lib/getUnboundedScrollPosition.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/node_modules/fbjs/lib/getUnboundedScrollPosition.js b/node_modules/fbjs/lib/getUnboundedScrollPosition.js
new file mode 100644
index 000000000..cec5fac91
--- /dev/null
+++ b/node_modules/fbjs/lib/getUnboundedScrollPosition.js
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2013-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @typechecks
+ */
+
+'use strict';
+
+/**
+ * Gets the scroll position of the supplied element or window.
+ *
+ * The return values are unbounded, unlike `getScrollPosition`. This means they
+ * may be negative or exceed the element boundaries (which is possible using
+ * inertial scrolling).
+ *
+ * @param {DOMWindow|DOMElement} scrollable
+ * @return {object} Map with `x` and `y` keys.
+ */
+
+function getUnboundedScrollPosition(scrollable) {
+ if (scrollable.Window && scrollable instanceof scrollable.Window) {
+ return {
+ x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft,
+ y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop
+ };
+ }
+ return {
+ x: scrollable.scrollLeft,
+ y: scrollable.scrollTop
+ };
+}
+
+module.exports = getUnboundedScrollPosition; \ No newline at end of file