修改代码

This commit is contained in:
ival 2019-07-15 18:31:13 +08:00
parent 5372284ff8
commit 88e69b6093
5 changed files with 23 additions and 6 deletions

View File

@ -128,7 +128,7 @@ fuzhouSkin[deviceType.Signal] = {
signalR: 7,
/** 灯柱宽度*/
signalLampStandardWidth: 1,
signalLampStandardWidth: 1.5,
/** 设备距离区段的距离*/
signalDistance: 13,

View File

@ -119,8 +119,26 @@ class Jmap {
if (this.methods.stateLoaded instanceof Function) { this.methods.stateLoaded(); }
}
pullBack(payload) {
if (payload.type === 'zoom') {
const zrWidth = this.$zr.getWidth();
const zrHeight = this.$zr.getHeight();
const originX = this.$options.zoomOnMouseWheel ? payload.originX : zrWidth / 2;
const originY = this.$options.zoomOnMouseWheel ? payload.originY : zrHeight / 2;
const x = (this.$options.offsetX + originX) / this.$options.scaleRate;
const y = (this.$options.offsetY + originY) / this.$options.scaleRate;
const newScaleRate = this.$options.getScaleRate(payload.scale);
const dx = originX - (x * newScaleRate - this.$options.offsetX);
const dy = originY - (y * newScaleRate - this.$options.offsetY);
payload.dx = dx;
payload.dy = dy;
}
return payload || {};
}
setOptions(zoom) {
this.$options.update(zoom); // 更新信息
this.$options.update(this.pullBack(zoom));
this.$painter.updateZoomTransform(this.$options);
if (this.methods.optionsUpdate instanceof Function) { this.methods.optionsUpdate(); }
}

View File

@ -138,7 +138,7 @@ class MouseController extends Eventful {
scale = -1;
}
this.trigger(this.events.Zoom, { scale, originX, originY });
this.trigger(this.events.Zoom, {type: 'zoom', scale, originX, originY });
}
}

View File

@ -1,5 +1,6 @@
class Options {
constructor(opts) {
constructor(opts, zr) {
this.$zr = zr;
this.scaleIndex = 0;
this.scaleList = [
0.5, 0.6, 0.7, 0.8, 0.9,
@ -38,7 +39,6 @@ class Options {
}
update(payload) {
payload = payload || {};
if (Number.isFinite(payload.dx)) {
this.offsetX -= payload.dx;
}

View File

@ -58,7 +58,6 @@ export function parser(data, jmap) {
});
zrUtil.each(data.zcList || [], elem => {
console.log(elem);
mapDevice[elem.code] = deviceFactory(deviceType.ZcControl, defaultStateDict, elem);
});