diff --git a/modules/bus/index.js b/modules/bus/index.js index b4631c54..0066ff1b 100644 --- a/modules/bus/index.js +++ b/modules/bus/index.js @@ -75,6 +75,8 @@ export default class Bus { } dispatch(key, data) { + console.log('dispatch: ' + key + ' -> ' + JSON.stringify(data)); + if (this.lock.has(key)) { console.warn('recursive dispatch'); return diff --git a/web/app/cad/actions/actionButtonBehavior.js b/web/app/cad/actions/actionButtonBehavior.js index 82efff47..f40abd49 100644 --- a/web/app/cad/actions/actionButtonBehavior.js +++ b/web/app/cad/actions/actionButtonBehavior.js @@ -4,9 +4,35 @@ export function mapActionBehavior(actionIdProp) { return ({dispatch}, props) => { const actionId = props[actionIdProp]; const actionRunToken = ACTION_TOKENS.actionRun(actionId); + + let request = {actionId, x:0, y:0}; + let canceled = true; + let showed = false; + + function updateCoords({pageX, pageY}) { + request.x = pageX + 10; + request.y = pageY + 10; + } + return { onClick: data => dispatch(actionRunToken, data), - onMouseEnter: ({pageX, pageY}) => dispatch(ACTION_TOKENS.SHOW_HINT_FOR, [actionId, pageX, pageY]), - onMouseLeave: () => dispatch(ACTION_TOKENS.SHOW_HINT_FOR, null) + onMouseEnter: e => { + updateCoords(e); + canceled = false; + showed = false; + setTimeout(() => { + if (!canceled) { + showed = true; + dispatch(ACTION_TOKENS.SHOW_HINT_FOR, request) + } + }, 500); + }, + onMouseMove: updateCoords, + onMouseLeave: () => { + canceled = true; + if (showed) { + dispatch(ACTION_TOKENS.SHOW_HINT_FOR, null) + } + } }}; -} \ No newline at end of file +} diff --git a/web/app/cad/actions/actionSystemPlugin.js b/web/app/cad/actions/actionSystemPlugin.js index 52ed23c3..15bc89dd 100644 --- a/web/app/cad/actions/actionSystemPlugin.js +++ b/web/app/cad/actions/actionSystemPlugin.js @@ -59,35 +59,18 @@ export function activate(context) { function synchActionHint(bus) { - let lastRequest = null; - - // bus.subscribe(TOKENS.REQUEST_SHOW_HINT_FOR bus.subscribe(TOKENS.SHOW_HINT_FOR, request => { - if (lastRequest !== null) { - if (request !== null) { - if (request[0] === lastRequest[0]) { - Object.assign(lastRequest, request); - return; - } - } - lastRequest.spoiled = true; - } - lastRequest = request; if (request) { - setTimeout(() => { - if (!request.spoiled) { - let [actionId, x, y] = request; - let actionState = bus.getState(TOKENS.actionState(actionId)); - let actionAppearance = bus.getState(TOKENS.actionAppearance(actionId)); - if (actionState && actionAppearance) { - bus.dispatch(TOKENS.HINT, { - actionId, x: x + 10, y: y + 10, - info: actionAppearance.info, - hint: actionState.hint - }); - } - } - }, 500); + let {actionId, x, y} = request; + let actionState = bus.getState(TOKENS.actionState(actionId)); + let actionAppearance = bus.getState(TOKENS.actionAppearance(actionId)); + if (actionState && actionAppearance) { + bus.dispatch(TOKENS.HINT, { + actionId, x, y, + info: actionAppearance.info, + hint: actionState.hint + }); + } } else { bus.dispatch(TOKENS.HINT, null); } diff --git a/web/app/cad/dom/actionInfo/ActionInfo.less b/web/app/cad/dom/actionInfo/ActionInfo.less index b86d86bc..0e1fd782 100644 --- a/web/app/cad/dom/actionInfo/ActionInfo.less +++ b/web/app/cad/dom/actionInfo/ActionInfo.less @@ -1,3 +1,4 @@ .root { display: flex; + pointer-events:none; } \ No newline at end of file