mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
fix menu position (#6611)
This commit is contained in:
@@ -14,6 +14,8 @@ const propTypes = {
|
||||
getMenuContainerSize: PropTypes.func,
|
||||
};
|
||||
|
||||
const MENU_BORDER_INDENT = 10;
|
||||
|
||||
class ContextMenu extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
@@ -155,8 +157,12 @@ class ContextMenu extends React.Component {
|
||||
innerHeight = parseFloat(containerSize.height);
|
||||
}
|
||||
|
||||
if (y + rect.height > innerHeight) {
|
||||
menuStyles.top -= rect.height;
|
||||
if (y + rect.height > innerHeight - MENU_BORDER_INDENT) {
|
||||
menuStyles.top = innerHeight - rect.height - MENU_BORDER_INDENT;
|
||||
}
|
||||
|
||||
if (x + rect.width > innerWidth - MENU_BORDER_INDENT) {
|
||||
menuStyles.left = innerWidth - rect.width - MENU_BORDER_INDENT;
|
||||
}
|
||||
|
||||
if (menuStyles.left < 0) {
|
||||
@@ -167,10 +173,6 @@ class ContextMenu extends React.Component {
|
||||
menuStyles.top = rect.height < innerHeight ? (innerHeight - rect.height) / 2 : 0;
|
||||
}
|
||||
|
||||
if (menuStyles.left + rect.width > innerWidth) {
|
||||
menuStyles.left = innerWidth - rect.width;
|
||||
}
|
||||
|
||||
return menuStyles;
|
||||
};
|
||||
|
||||
|
@@ -129,7 +129,8 @@ class DirColumnView extends React.Component {
|
||||
};
|
||||
|
||||
getMenuContainerSize = () => {
|
||||
return window.getComputedStyle(this.viewModeContainer.current);
|
||||
const { innerWidth, innerHeight } = window;
|
||||
return { width: innerWidth, height: innerHeight };
|
||||
};
|
||||
|
||||
render() {
|
||||
|
Reference in New Issue
Block a user