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

73 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-16 16:03:56 +08:00
import Group from 'zrender/src/container/Group';
import Line from 'zrender/src/graphic/shape/Line';
2019-07-22 13:39:33 +08:00
/** 延时释放*/
export default class ERelease extends Group {
2019-07-16 16:03:56 +08:00
constructor(model) {
super();
this.model = model;
2019-07-24 14:33:50 +08:00
this.isNew = false;
2019-07-16 16:03:56 +08:00
}
2019-07-31 14:59:38 +08:00
create() {
2019-07-24 14:33:50 +08:00
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);
}
2019-07-16 16:03:56 +08:00
}
setStyle(model) {
2019-07-31 14:59:38 +08:00
this.create();
2019-07-24 14:33:50 +08:00
this.lines.setStyle(model);
2019-07-16 16:03:56 +08:00
}
hide() {
2019-07-31 14:59:38 +08:00
this.create();
2019-07-24 14:33:50 +08:00
this.lines.hide();
2019-07-16 16:03:56 +08:00
}
show() {
2019-07-31 14:59:38 +08:00
this.create();
2019-07-24 14:33:50 +08:00
this.lines.show();
2019-07-16 16:03:56 +08:00
}
// 开始动画
animateStyle(loop, animates) {
2019-07-31 14:59:38 +08:00
this.create();
2019-07-16 16:03:56 +08:00
if (animates && animates.length) {
this.eachChild((child) => {
2019-07-24 14:33:50 +08:00
if (child.animateStyle) {
2019-07-16 16:03:56 +08:00
let an = child.animateStyle(loop);
animates.forEach(elem => {
an = an.when(elem.time, elem.styles);
});
an.start();
}
});
}
}
// 结束动画
stopAnimation(flag) {
2019-07-31 14:59:38 +08:00
this.create();
2019-07-16 16:03:56 +08:00
this.eachChild((child) => {
2019-07-24 14:33:50 +08:00
if (child.stopAnimation) {
2019-07-16 16:03:56 +08:00
child.stopAnimation(flag);
}
});
}
}