From 46ba154e5a61ff1bd674d4cb2f6c32121694c58b Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Sun, 24 Nov 2019 11:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E4=B8=AA=E7=AE=80=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7=E8=BF=99?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E7=B3=BB=E7=BB=9F=E5=8F=B3=E9=94=AE=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scss/components/_context-menu.scss | 18 ++++++++++++++++- src/components/ContextMenu.tsx | 32 +++++++++++++++--------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/scss/components/_context-menu.scss b/scss/components/_context-menu.scss index 96abcf61..4b48c120 100644 --- a/scss/components/_context-menu.scss +++ b/scss/components/_context-menu.scss @@ -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 { from { opacity: 0; @@ -24,7 +39,8 @@ } &.in { - animation-name: contextMenuIn; + animation-name: contextMenuInSpecial; + animation-duration: 0.5s; } &.out { diff --git a/src/components/ContextMenu.tsx b/src/components/ContextMenu.tsx index 546ae23f..edd20314 100644 --- a/src/components/ContextMenu.tsx +++ b/src/components/ContextMenu.tsx @@ -73,13 +73,13 @@ export class ContextMenu extends React.Component< } componentDidMount() { - document.body.addEventListener('click', this.handleOutClick, true); + // document.body.addEventListener('click', this.handleOutClick, true); document.addEventListener('keydown', this.handleKeyDown); } componentWillUnmount() { ContextMenu.instance = null; - document.body.removeEventListener('click', this.handleOutClick, true); + // document.body.removeEventListener('click', this.handleOutClick, true); document.removeEventListener('keydown', this.handleKeyDown); } @@ -103,20 +103,20 @@ export class ContextMenu extends React.Component< }); } - @autobind - handleOutClick(e: Event) { - if ( - !e.target || - !this.menuRef.current || - this.menuRef.current.contains(e.target as HTMLElement) - ) { - return; - } - if (this.state.isOpened) { - e.preventDefault(); - this.close(); - } - } + // @autobind + // handleOutClick(e: Event) { + // if ( + // !e.target || + // !this.menuRef.current || + // this.menuRef.current.contains(e.target as HTMLElement) + // ) { + // return; + // } + // if (this.state.isOpened) { + // e.preventDefault(); + // this.close(); + // } + // } handleClick(item: MenuItem) { item.disabled ||