Skip to content

Commit

Permalink
Fixed window scroll position for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Kim committed Mar 7, 2018
1 parent 5dfb647 commit f961ba0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-popup",
"version": "3.0.2",
"version": "3.0.3",
"description": "React redux popup",
"license": "MIT",
"main": "lib/react-redux-popup",
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ describe('utils', () => {
});

it('should anchor to bottom when enough space below and window has scrolled', () => {
window.scrollX = 20;
window.scrollY = 30;
window.pageXOffset = 20;
window.pageYOffset = 30;

const anchor = 'bottom';
const rect = { bottom: 50, left: 10, right: 50, top: 10 };
Expand All @@ -493,8 +493,8 @@ describe('utils', () => {
});

it('should anchor to top when enough space above and window has scrolled', () => {
window.scrollX = 20;
window.scrollY = 30;
window.pageXOffset = 20;
window.pageYOffset = 30;

const anchor = 'top';
const rect = { bottom: 290, left: 10, right: 50, top: 250 };
Expand All @@ -519,8 +519,8 @@ describe('utils', () => {
});

it('should anchor to right when enough space on the right and window has scrolled', () => {
window.scrollX = 20;
window.scrollY = 30;
window.pageXOffset = 20;
window.pageYOffset = 30;

const anchor = 'right';
const rect = { bottom: 50, left: 10, right: 50, top: 10 };
Expand All @@ -545,8 +545,8 @@ describe('utils', () => {
});

it('should anchor to left when enough space on the left and window has scrolled', () => {
window.scrollX = 20;
window.scrollY = 30;
window.pageXOffset = 20;
window.pageYOffset = 30;

const anchor = 'left';
const rect = { bottom: 50, left: 250, right: 290, top: 10 };
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export function getPopupPosition(
windowWidth,
popupWidth,
rect.left,
rect.right) + window.scrollX,
rect.right) + window.pageXOffset,
top: calculatePosition(
windowHeight,
popupHeight,
rect.top,
rect.bottom,
offset,
anchor === 'bottom') + window.scrollY,
anchor === 'bottom') + window.pageYOffset,
};
default: // left and right
return {
Expand All @@ -64,12 +64,12 @@ export function getPopupPosition(
rect.left,
rect.right,
offset,
anchor === 'right') + window.scrollX,
anchor === 'right') + window.pageXOffset,
top: adjustPosition(
windowHeight,
popupHeight,
rect.top,
rect.bottom) + window.scrollY,
rect.bottom) + window.pageYOffset,
};
}
}

0 comments on commit f961ba0

Please sign in to comment.