@@ -2,6 +2,7 @@ import i18n from '../i18n'
22import type { Topic } from '../types/dom'
33import type { MindElixirInstance } from '../types/index'
44import { encodeHTML , isTopic } from '../utils/index'
5+ import dragMoveHelper from '../utils/dragMoveHelper'
56import './contextMenu.less'
67
78export default function ( mind : MindElixirInstance , option : any ) {
@@ -91,21 +92,36 @@ export default function (mind: MindElixirInstance, option: any) {
9192 }
9293 if ( ! mind . currentNodes ) mind . selectNode ( target )
9394 menuContainer . hidden = false
95+
96+ if ( dragMoveHelper . mousedown ) {
97+ dragMoveHelper . mousedown = false
98+ }
99+
100+ menuUl . style . top = ''
101+ menuUl . style . bottom = ''
102+ menuUl . style . left = ''
103+ menuUl . style . right = ''
104+ const rect = menuUl . getBoundingClientRect ( )
94105 const height = menuUl . offsetHeight
95106 const width = menuUl . offsetWidth
96- if ( height + e . clientY > window . innerHeight ) {
107+
108+ const relativeY = e . clientY - rect . top
109+ const relativeX = e . clientX - rect . left
110+
111+ if ( height + relativeY > window . innerHeight ) {
97112 menuUl . style . top = ''
98113 menuUl . style . bottom = '0px'
99114 } else {
100115 menuUl . style . bottom = ''
101- menuUl . style . top = e . clientY + 15 + 'px'
116+ menuUl . style . top = relativeY + 15 + 'px'
102117 }
103- if ( width + e . clientX > window . innerWidth ) {
118+
119+ if ( width + relativeX > window . innerWidth ) {
104120 menuUl . style . left = ''
105121 menuUl . style . right = '0px'
106122 } else {
107123 menuUl . style . right = ''
108- menuUl . style . left = e . clientX + 10 + 'px'
124+ menuUl . style . left = relativeX + 10 + 'px'
109125 }
110126 }
111127 }
0 commit comments