import Group from 'zrender/src/container/Group'; import Rect from 'zrender/src/graphic/shape/Rect'; export default class EMouse extends Group { constructor(device) { super(); this.device = device; this.selected = false; this.create(); } create() { if (this.device) { const stationTextRect = this.device.stationText.getBoundingRect(); const path = window.location.href; if (this.device.style.Station.kmPostShow || path.includes('/map/draw')) { const mileageTextRect = this.device.mileageText.getBoundingRect(); stationTextRect.union(mileageTextRect); } this.lineBorder = new Rect({ zlevel: this.device.zlevel, z: this.device.z + 1, shape: stationTextRect, style: { lineDash: [3, 3], stroke: '#fff', fill: 'rgba(204,255,255,0.5)' } }); this.add(this.lineBorder); this.lineBorder.hide(); } } mouseover() { this.lineBorder && this.lineBorder.show(); } mouseout() { !this.selected && this.lineBorder && this.lineBorder.hide(); } drawSelected(selected) { if (selected && this.lineBorder) { this.lineBorder && this.lineBorder.show(); this.selected = true; } else { this.lineBorder && this.lineBorder.hide(); this.selected = false; } } }