55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
export default class EMouse extends Group {
|
|
constructor(device) {
|
|
super();
|
|
this.device = device;
|
|
this.create();
|
|
}
|
|
create() {
|
|
this.text = new Text({
|
|
_subType: 'Text',
|
|
zlevel: this.device.zlevel,
|
|
z: this.device.z+1,
|
|
position: [0, 0],
|
|
style: {
|
|
x: this.device.model.position.x,
|
|
y: this.device.model.position.y + this.device.style.ZcControl.lamp.radiusR + this.device.style.ZcControl.text.distance-30,
|
|
fontWeight: this.device.style.ZcControl.mouseOverStyle.fontWeight,
|
|
fontSize: this.device.style.ZcControl.mouseOverStyle.fontSize,
|
|
fontFamily: this.device.style.ZcControl.mouseOverStyle.fontFormat,
|
|
text: this.device.model.name,
|
|
textFill: this.device.style.ZcControl.mouseOverStyle.fontColor,
|
|
textAlign: this.device.style.ZcControl.mouseOverStyle.textAlign,
|
|
textVerticalAlign: this.device.style.ZcControl.mouseOverStyle.textVerticalAlign
|
|
}
|
|
});
|
|
this.add(this.text);
|
|
this.text.hide();
|
|
}
|
|
mouseover(e) {
|
|
if (e.target && e.target._subType == 'Text') {
|
|
this.text.show();
|
|
} else {
|
|
this.device.control.setControlColor(this.device.style.ZcControl.mouseOverStyle.arcColor);
|
|
this.device.control.setTextColor(this.device.style.ZcControl.mouseOverStyle.textColor);
|
|
this.device.control.setTextBorder(true);
|
|
this.device.control.setArcBorder(true);
|
|
}
|
|
}
|
|
|
|
mouseout(e) {
|
|
if (!this.device.model.down) {
|
|
if (e.target && e.target._subType == 'Text') {
|
|
this.text.hide();
|
|
} else {
|
|
this.device.control.setControlColor(this.device.style.ZcControl.lamp.controlColor);
|
|
this.device.control.setTextColor('#FFFFFF');
|
|
this.device.control.setTextBorder(false);
|
|
this.device.control.setArcBorder(false);
|
|
}
|
|
}
|
|
}
|
|
}
|