We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e60e47d commit 18c0234Copy full SHA for 18c0234
src/Selection.js
@@ -224,8 +224,8 @@ export function getBoundsForNode(node) {
224
if (!node.getBoundingClientRect) return node;
225
226
var rect = node.getBoundingClientRect()
227
- , left = rect.left + (document.body.scrollLeft || 0)
228
- , top = rect.top + (document.body.scrollTop || 0);
+ , left = rect.left + pageOffset('left')
+ , top = rect.top + pageOffset('top');
229
230
return {
231
top,
@@ -235,4 +235,10 @@ export function getBoundsForNode(node) {
235
};
236
}
237
238
+function pageOffset(dir) {
239
+ if (dir === 'left')
240
+ return (window.pageXOffset || document.body.scrollLeft || 0)
241
+ if (dir === 'top')
242
+ return (window.pageYOffset || document.body.scrollTop || 0)
243
+}
244
export default Selection
0 commit comments