Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit b92a300

Browse files
authored
Merge pull request #31 from andreascreten/patch-1
Correct position of the menu when out of viewport
2 parents 6f4f1c6 + 212ce3e commit b92a300

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/context-menu/wrapper.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ let ContextMenuWrapper = React.createClass({
6464
if (x + rect.width > innerWidth) {
6565
menuStyles.left -= rect.width;
6666
}
67+
68+
if (menuStyles.top < 0) {
69+
menuStyles.top = (rect.height < innerHeight) ? (innerHeight - rect.height) / 2 : 0;
70+
}
71+
72+
if (menuStyles.left < 0) {
73+
menuStyles.left = (rect.width < innerWidth) ? (innerWidth - rect.width) / 2 : 0;
74+
}
6775

6876
return menuStyles;
6977
},

0 commit comments

Comments
 (0)