用个简单的动画提示用户这不是系统右键菜单
This commit is contained in:
parent
64f22a74a0
commit
46ba154e5a
|
@ -1,3 +1,18 @@
|
||||||
|
// 为了提示用户这不是系统菜单。
|
||||||
|
@keyframes contextMenuInSpecial {
|
||||||
|
from {
|
||||||
|
transform: scale3d(1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: scale3d(1.05, 1.05, 1.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
transform: scale3d(1, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes contextMenuIn {
|
@keyframes contextMenuIn {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
@ -24,7 +39,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.in {
|
&.in {
|
||||||
animation-name: contextMenuIn;
|
animation-name: contextMenuInSpecial;
|
||||||
|
animation-duration: 0.5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.out {
|
&.out {
|
||||||
|
|
|
@ -73,13 +73,13 @@ export class ContextMenu extends React.Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
document.body.addEventListener('click', this.handleOutClick, true);
|
// document.body.addEventListener('click', this.handleOutClick, true);
|
||||||
document.addEventListener('keydown', this.handleKeyDown);
|
document.addEventListener('keydown', this.handleKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
ContextMenu.instance = null;
|
ContextMenu.instance = null;
|
||||||
document.body.removeEventListener('click', this.handleOutClick, true);
|
// document.body.removeEventListener('click', this.handleOutClick, true);
|
||||||
document.removeEventListener('keydown', this.handleKeyDown);
|
document.removeEventListener('keydown', this.handleKeyDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,20 +103,20 @@ export class ContextMenu extends React.Component<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
// @autobind
|
||||||
handleOutClick(e: Event) {
|
// handleOutClick(e: Event) {
|
||||||
if (
|
// if (
|
||||||
!e.target ||
|
// !e.target ||
|
||||||
!this.menuRef.current ||
|
// !this.menuRef.current ||
|
||||||
this.menuRef.current.contains(e.target as HTMLElement)
|
// this.menuRef.current.contains(e.target as HTMLElement)
|
||||||
) {
|
// ) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (this.state.isOpened) {
|
// if (this.state.isOpened) {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
this.close();
|
// this.close();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
handleClick(item: MenuItem) {
|
handleClick(item: MenuItem) {
|
||||||
item.disabled ||
|
item.disabled ||
|
||||||
|
|
Loading…
Reference in New Issue