rt-sim-training-client/src/jmap/shape/Section/ERelease.js
2019-07-31 14:59:38 +08:00

73 lines
1.2 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import Line from 'zrender/src/graphic/shape/Line';
/** 延时释放*/
export default class ERelease extends Group {
constructor(model) {
super();
this.model = model;
this.isNew = false;
}
create() {
if (!this.isNew) {
const model = this.model;
this.isNew = true;
this.lines = new Line({
zlevel: model.zlevel,
z: model.z,
shape: model.shape,
progressive: model.progressive,
style: {
lineWidth: model.lineWidth,
stroke: model.stroke
}
});
this.add(this.lines);
}
}
setStyle(model) {
this.create();
this.lines.setStyle(model);
}
hide() {
this.create();
this.lines.hide();
}
show() {
this.create();
this.lines.show();
}
// 开始动画
animateStyle(loop, animates) {
this.create();
if (animates && animates.length) {
this.eachChild((child) => {
if (child.animateStyle) {
let an = child.animateStyle(loop);
animates.forEach(elem => {
an = an.when(elem.time, elem.styles);
});
an.start();
}
});
}
}
// 结束动画
stopAnimation(flag) {
this.create();
this.eachChild((child) => {
if (child.stopAnimation) {
child.stopAnimation(flag);
}
});
}
}