mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2026-03-13 09:50:09 +08:00
deserialize labels correctly
This commit is contained in:
@@ -58,11 +58,15 @@ export class DefaultLinkWidget extends React.Component<DefaultLinkProps, Default
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
|
||||
if(this.props.link.labels.length > 0){
|
||||
window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
|
||||
if(this.props.link.labels.length > 0) {
|
||||
window.requestAnimationFrame(this.calculateAllLabelPosition.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
addPointToLink = (event: MouseEvent, index: number): void => {
|
||||
|
||||
@@ -38,7 +38,12 @@ export class LinkModel<T extends LinkModelListener = LinkModelListener> extends
|
||||
return p;
|
||||
});
|
||||
|
||||
this.labels = ob.label || null;
|
||||
//deserialize labels
|
||||
_.forEach(ob.labels || [], (label: any) => {
|
||||
let labelOb = engine.getLabelFactory(label.type).getNewInstance();
|
||||
labelOb.deSerialize(label, engine);
|
||||
this.addLabel(labelOb);
|
||||
});
|
||||
|
||||
if (ob.target) {
|
||||
this.setTargetPort(
|
||||
|
||||
Reference in New Issue
Block a user