修改代码
This commit is contained in:
parent
c912074739
commit
058e688602
@ -130,7 +130,8 @@ class Jmap {
|
||||
}
|
||||
|
||||
setOptions(opts) {
|
||||
this.$options.update(this.pullBack(opts));
|
||||
const options = this.pullBack(opts);
|
||||
this.$options.update(options);
|
||||
this.$painter.updateTransform(this.$options);
|
||||
if (this.methods.optionsUpdate instanceof Function) { this.methods.optionsUpdate(); }
|
||||
if (this.$options.disabled == true) {
|
||||
|
@ -37,14 +37,14 @@ class MouseController extends Eventful {
|
||||
|
||||
initHandler(zr) {
|
||||
if (zr) {
|
||||
const clickHandler = this.click.bind(this);
|
||||
const contextmenuHandler = this.contextmenu.bind(this);
|
||||
const moveEventHandler = this.moveEvent.bind(this);
|
||||
const clickHandler = click.bind(this);
|
||||
const contextmenuHandler = contextmenu.bind(this);
|
||||
const moveEventHandler = moveEvent.bind(this);
|
||||
|
||||
const mousedownHandler = this.mousedown.bind(this);
|
||||
const mousemoveHandler = this.mousemove.bind(this);
|
||||
const mouseupHandler = this.mouseup.bind(this);
|
||||
const mousewheelHandler = this.mousewheel.bind(this);
|
||||
const mousedownHandler = mousedown.bind(this);
|
||||
const mousemoveHandler = mousemove.bind(this);
|
||||
const mouseupHandler = mouseup.bind(this);
|
||||
const mousewheelHandler = mousewheel.bind(this);
|
||||
|
||||
zr.on('click', clickHandler);
|
||||
zr.on('contextmenu', contextmenuHandler);
|
||||
@ -81,18 +81,22 @@ class MouseController extends Eventful {
|
||||
this.isDragging = function () { return this._dragging; };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mousedown(e) {
|
||||
function mousedown(e) {
|
||||
if (eventTool.notLeftMouse(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._x = e.offsetX;
|
||||
this._y = e.offsetY;
|
||||
var x = e.offsetX;
|
||||
var y = e.offsetY;
|
||||
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._dragging = true;
|
||||
}
|
||||
|
||||
mousemove(e) {
|
||||
function mousemove(e) {
|
||||
if (eventTool.notLeftMouse(e) ||
|
||||
!this._moveOnMouseMove ||
|
||||
!this._dragging
|
||||
@ -114,13 +118,13 @@ class MouseController extends Eventful {
|
||||
this.trigger(this.events.Pan, { dx, dy, oldX, oldY, newX: this._x, newY: this._y });
|
||||
}
|
||||
|
||||
mouseup(e) {
|
||||
function mouseup(e) {
|
||||
if (!eventTool.notLeftMouse(e)) {
|
||||
this._dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
mousewheel(e) {
|
||||
function mousewheel(e) {
|
||||
const shouldZoom = this._zoomOnMouseWheel;
|
||||
const wheelDelta = e.wheelDelta;
|
||||
const originX = e.offsetX;
|
||||
@ -143,24 +147,22 @@ class MouseController extends Eventful {
|
||||
}
|
||||
}
|
||||
|
||||
click(e) {
|
||||
var em = this.checkEvent(e);
|
||||
function click(e) {
|
||||
var em = checkEvent(e);
|
||||
this.trigger(this.events.Selected, em);
|
||||
}
|
||||
|
||||
contextmenu(e) {
|
||||
var em = this.checkEvent(e);
|
||||
function contextmenu(e) {
|
||||
var em = checkEvent(e);
|
||||
this.trigger(this.events.Contextmenu, em);
|
||||
}
|
||||
|
||||
moveEvent(e) {
|
||||
function moveEvent(e) {
|
||||
return new EventModel(e);
|
||||
}
|
||||
|
||||
checkEvent(e) {
|
||||
function checkEvent(e) {
|
||||
return new EventModel(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default MouseController;
|
||||
|
@ -10,14 +10,14 @@ class Painter {
|
||||
this.$jmap = jmap;
|
||||
this.$zr = jmap.getZr();
|
||||
|
||||
// 视图控制器
|
||||
this.$transformHandle = new TransformHandle(this, this.$zr);
|
||||
|
||||
// 图层数据
|
||||
this.mapInstanceLevel = {};
|
||||
|
||||
// 初始图层
|
||||
this.initPainterLevels();
|
||||
|
||||
// 视图控制器
|
||||
this.$transformHandle = new TransformHandle(this, this.$zr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Group from 'zrender/src/container/Group';
|
||||
// import Group from 'zrender/src/container/Group';
|
||||
import * as matrix from 'zrender/src/core/matrix';
|
||||
|
||||
function createTransform(zoom) {
|
||||
@ -25,6 +25,10 @@ class TransformHandle {
|
||||
this.$painter = painter;
|
||||
this.$zr = zr;
|
||||
|
||||
this.parentLevel = this.$painter.getParentLevel();
|
||||
|
||||
console.log(this.parentLevel, 1111);
|
||||
|
||||
this.rect = { x: 0, y: 0, width: this.$zr.getWidth(), height: this.$zr.getHeight() };
|
||||
this.transform = createTransform({ scaleRate: 1, offsetX: 0, offsetY: 0 });
|
||||
}
|
||||
@ -56,26 +60,26 @@ class TransformHandle {
|
||||
|
||||
// 处理所有视图缩放/平移
|
||||
transformAll() {
|
||||
const parentLevel = this.$painter.getParentLevel();
|
||||
if (parentLevel instanceof Group) {
|
||||
parentLevel.eachChild((level) => {
|
||||
// const parentLevel = this.$painter.getParentLevel();
|
||||
// if (parentLevel instanceof Group) {
|
||||
this.parentLevel.eachChild((level) => {
|
||||
level.eachChild((view) => {
|
||||
this.transformView(view);
|
||||
});
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
}, this);
|
||||
// }
|
||||
}
|
||||
|
||||
// 重新计算显示图形
|
||||
revisibleAll() {
|
||||
const parentLevel = this.$painter.getParentLevel();
|
||||
if (parentLevel instanceof Group) {
|
||||
parentLevel.eachChild((level) => {
|
||||
// const parentLevel = this.$painter.getParentLevel();
|
||||
// if (parentLevel instanceof Group) {
|
||||
this.parentLevel.eachChild((level) => {
|
||||
level.eachChild((view) => {
|
||||
this.revisibleView(view);
|
||||
});
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
}, this);
|
||||
// }
|
||||
}
|
||||
|
||||
// 更新偏移量
|
||||
|
Loading…
Reference in New Issue
Block a user