优化界面手标操作

This commit is contained in:
ival 2021-04-01 13:33:03 +08:00
parent 67c5425b67
commit 28242e5a2c
6 changed files with 29 additions and 28 deletions

View File

@ -48,7 +48,6 @@ export default class Controller extends Eventful {
this._isNotLeftMouse = false;
this._shortcuts = '';
this._distance = 0;
this._locking = false;
this._target = null;
this.initModule(map);
this.initHandler(map);
@ -147,9 +146,11 @@ export default class Controller extends Eventful {
}
isSelected(code) {
return this.$controller
? this.$controller.storage.has(code)
: false;
return this.storage.has(code)
}
setTarget(target) {
this._target = target;
}
setCursorStyle(cursorStyle) {
@ -189,11 +190,13 @@ export default class Controller extends Eventful {
} else {
this.selectingHandle.clear(e);
if (this.isSpecialSubType(event)) { return; }
if (this._dragEnable && this._locking) {
this.trigger(this.events.__DragStart, { x: e.offsetX, y: e.offsetY, code: event.code });
} else if (this._areaSelectEnable) {
if (this._areaSelectEnable) {
this.trigger(this.events.__SelectStart, { x: e.offsetX, y: e.offsetY});
}
if (this._dragEnable) {
this.trigger(this.events.__DragStart, { x: e.offsetX, y: e.offsetY, code: event.code });
}
}
}
@ -240,7 +243,9 @@ export default class Controller extends Eventful {
} else {
if (this._dragEnable && this.dragHandle.isDragging()) {
this.trigger(this.events.__DragEnd, {x: e.offsetX, y: e.offsetY});
} else if (this._areaSelectEnable && this.selectingHandle.isSelecting()) {
}
if (this._areaSelectEnable && this.selectingHandle.isSelecting()) {
this.trigger(this.events.__SelectEnd, { x: e.offsetX, y: e.offsetY });
}
@ -281,9 +286,7 @@ export default class Controller extends Eventful {
const event = new MouseEvent(this, e);
this.trigger(events.Selected, event);
if (event.code) {
this.setLocking(true)
} else {
if (!event.code) {
this.selectHandle.clear();
this.selectingHandle.clear();
this.clear();
@ -331,7 +334,6 @@ export default class Controller extends Eventful {
this.storage.clear();
this.storage.clearClipboard();
this._pan = false;
this._locking = false;
}
getKeyStr() {
@ -342,10 +344,6 @@ export default class Controller extends Eventful {
return this._target;
}
setLocking(lock=false) {
this._locking = lock;
}
destroy () {
this.dispose();
}

View File

@ -1,12 +1,12 @@
import * as graphic from '../core/graphic';
import shapeRender from '../constant/shapeRender';
function shapeStyleBuilder() {
function shapeStyleBuilder(model) {
return {
code: model.code,
subType: '__hover__',
...shapeRender,
z: 9998,
silent: true,
cursor: 'pointer',
shape: {
x: 0,
@ -28,7 +28,7 @@ class AbstractShape {
this.model = model;
this.option = option;
this.shapeFactory = shapeFactory;
this.hightLightInstance = new graphic.Rect(shapeStyleBuilder());
this.hightLightInstance = new graphic.Rect(shapeStyleBuilder(this.model));
}
// 拖动

View File

@ -29,7 +29,7 @@ function shapeStyleBuilder() {
height: 0
},
style: {
lineDash: [3, 6],
lineDash: [4, 4],
lineWidth: 1,
stroke: '#000',
fill: 'transparent'

View File

@ -18,6 +18,7 @@ export default class SelectHandle {
this.e = {...e};
if (['Control'].includes(this.$controller.getKeyStr())) {
if (this.$controller.isSelected(e.target.model.code)) {
this.$controller.setTarget(null);
this.delSelected(e.target);
} else {
this.addSelected(e.target);

View File

@ -57,12 +57,8 @@ export default class SelectingHandle {
const selectingRect = this.selecting.getBoundingRect();
Object.values(this.$map.getMapShape()).forEach(el => {
if (el.model && this.checkSelectingRectContainShape(selectingRect, el)) {
if (!el.model.composeCode) {
this.setSelected(el);
this.$controller.setLocking(true);
// el.shapeFactory.showHightLight(el);
}
if (el.model && !el.model.composeCode && this.checkSelectingRectContainShape(selectingRect, el)) {
this.setSelected(el);
}
});

View File

@ -227,12 +227,18 @@ export default {
code: '100',
type: 'Device',
elementCodes: ['1', '2'],
composeCode: '101',
composeCode: '1000',
},
{
code: '101',
type: 'Device',
elementCodes: ['3', '4', '100'],
elementCodes: ['3', '4'],
composeCode: '1000'
},
{
code: '1000',
type: 'Combine',
elementCodes: ['100', '101'],
composeCode: ''
}
]