rt-sim-training-client/src/jmapNew/shape/Section/ERelease.js

73 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
import Group from 'zrender/src/container/Group';
import Line from 'zrender/src/graphic/shape/Line';
/** 延时释放*/
export default class ERelease extends Group {
2020-03-13 15:06:14 +08:00
constructor(model) {
super();
this.model = model;
this.isNew = false;
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
create() {
if (!this.isNew) {
const model = this.model;
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
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);
}
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
setStyle(model) {
this.create();
this.lines.setStyle(model);
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
hide() {
this.create();
this.lines.hide();
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
show() {
this.create();
this.lines.show();
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
// 开始动画
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();
}
});
}
}
2019-11-29 12:51:58 +08:00
2020-03-13 15:06:14 +08:00
// 结束动画
stopAnimation(flag) {
this.create();
this.eachChild((child) => {
if (child.stopAnimation) {
child.stopAnimation(flag);
}
});
}
2019-11-29 12:51:58 +08:00
}