mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
auto position mode when contextMenu
This commit is contained in:
parent
fd96967c87
commit
16e42601d6
@ -25,7 +25,7 @@ const menu = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Dropdown overlay={menu} trigger={['contextMenu']} alignPoint>
|
<Dropdown overlay={menu} trigger={['contextMenu']}>
|
||||||
<span style={{ userSelect: 'none' }}>Right Click on Me</span>
|
<span style={{ userSelect: 'none' }}>Right Click on Me</span>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
, mountNode);
|
, mountNode);
|
||||||
|
@ -68,11 +68,19 @@ export default class Dropdown extends React.Component<DropDownProps, any> {
|
|||||||
selectable,
|
selectable,
|
||||||
focusable,
|
focusable,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const triggerActions = disabled ? [] : trigger;
|
||||||
|
let alignPoint;
|
||||||
|
if (triggerActions && triggerActions.indexOf('contextMenu') !== -1) {
|
||||||
|
alignPoint = true;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RcDropdown
|
<RcDropdown
|
||||||
|
alignPoint={alignPoint}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
transitionName={this.getTransitionName()}
|
transitionName={this.getTransitionName()}
|
||||||
trigger={disabled ? [] : trigger}
|
trigger={triggerActions}
|
||||||
overlay={fixedModeOverlay}
|
overlay={fixedModeOverlay}
|
||||||
>
|
>
|
||||||
{dropdownTrigger}
|
{dropdownTrigger}
|
||||||
|
@ -23,7 +23,6 @@ If there are too many operations to display, you can wrap them in a `Dropdown`.
|
|||||||
| trigger | the trigger mode which executes the drop-down action | Array<`click`\|`hover`\|`contextMenu`> | `['hover']` |
|
| trigger | the trigger mode which executes the drop-down action | Array<`click`\|`hover`\|`contextMenu`> | `['hover']` |
|
||||||
| visible | whether the dropdown menu is visible | boolean | - |
|
| visible | whether the dropdown menu is visible | boolean | - |
|
||||||
| onVisibleChange | a callback function takes an argument: `visible`, is executed when the visible state is changed | Function(visible) | - |
|
| onVisibleChange | a callback function takes an argument: `visible`, is executed when the visible state is changed | Function(visible) | - |
|
||||||
| alignPoint | whether the dropdown menu follow the mouse position | bool | - |
|
|
||||||
|
|
||||||
You should use [Menu](/components/menu/) as `overlay`. The menu items and dividers are also available by using `Menu.Item` and `Menu.Divider`.
|
You should use [Menu](/components/menu/) as `overlay`. The menu items and dividers are also available by using `Menu.Item` and `Menu.Divider`.
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ title: Dropdown
|
|||||||
| trigger | 触发下拉的行为 | Array<`click`\|`hover`\|`contextMenu`> | `['hover']` |
|
| trigger | 触发下拉的行为 | Array<`click`\|`hover`\|`contextMenu`> | `['hover']` |
|
||||||
| visible | 菜单是否显示 | boolean | - |
|
| visible | 菜单是否显示 | boolean | - |
|
||||||
| onVisibleChange | 菜单显示状态改变时调用,参数为 visible | Function(visible) | - |
|
| onVisibleChange | 菜单显示状态改变时调用,参数为 visible | Function(visible) | - |
|
||||||
| alignPoint | 菜单是否跟随鼠标位置 | bool | - |
|
|
||||||
|
|
||||||
`overlay` 菜单使用 [Menu](/components/menu/),还包括菜单项 `Menu.Item`,分割线 `Menu.Divider`。
|
`overlay` 菜单使用 [Menu](/components/menu/),还包括菜单项 `Menu.Item`,分割线 `Menu.Divider`。
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user