Revert "Wait for other callbacks before load SVG code (#755)"

This reverts commit 2d277581b1.
This commit is contained in:
Paul Kaplan 2018-11-09 13:01:58 -05:00 committed by GitHub
parent e4e316fdbb
commit dd35871076

View file

@ -27,7 +27,6 @@ class PaperCanvas extends React.Component {
bindAll(this, [
'setCanvas',
'importSvg',
'initializeSvg',
'maybeZoomToFit',
'switchCostume'
]);
@ -172,17 +171,6 @@ class PaperCanvas extends React.Component {
performSnapshot(paperCanvas.props.undoSnapshot, Formats.VECTOR_SKIP_CONVERT);
return;
}
item.remove();
// Without the callback, rasters' load function has not been called yet, and they are
// positioned incorrectly
window.setTimeout(() => {
paperCanvas.initializeSvg(item, rotationCenterX, rotationCenterY, viewBox);
}, 0);
}
});
}
initializeSvg (item, rotationCenterX, rotationCenterY, viewBox) {
const itemWidth = item.bounds.width;
const itemHeight = item.bounds.height;
@ -219,7 +207,6 @@ class PaperCanvas extends React.Component {
item.translate(new paper.Point(ART_BOARD_WIDTH / 2, ART_BOARD_HEIGHT / 2)
.subtract(itemWidth, itemHeight));
}
paper.project.activeLayer.insertChild(0, item);
if (isGroup(item)) {
// Fixes an issue where we may export empty groups
for (const child of item.children) {
@ -229,7 +216,13 @@ class PaperCanvas extends React.Component {
}
ungroupItems([item]);
}
performSnapshot(this.props.undoSnapshot, Formats.VECTOR_SKIP_CONVERT);
// Without the callback, the transforms sometimes don't finish applying before the
// snapshot is taken.
window.setTimeout(
() => performSnapshot(paperCanvas.props.undoSnapshot, Formats.VECTOR_SKIP_CONVERT), 0);
}
});
}
setCanvas (canvas) {
this.canvas = canvas;