mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-10 06:32:07 -05:00
Revert "Wait for other callbacks before load SVG code (#755)"
This reverts commit 2d277581b1
.
This commit is contained in:
parent
e4e316fdbb
commit
dd35871076
1 changed files with 49 additions and 56 deletions
|
@ -27,7 +27,6 @@ class PaperCanvas extends React.Component {
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'setCanvas',
|
'setCanvas',
|
||||||
'importSvg',
|
'importSvg',
|
||||||
'initializeSvg',
|
|
||||||
'maybeZoomToFit',
|
'maybeZoomToFit',
|
||||||
'switchCostume'
|
'switchCostume'
|
||||||
]);
|
]);
|
||||||
|
@ -172,17 +171,6 @@ class PaperCanvas extends React.Component {
|
||||||
performSnapshot(paperCanvas.props.undoSnapshot, Formats.VECTOR_SKIP_CONVERT);
|
performSnapshot(paperCanvas.props.undoSnapshot, Formats.VECTOR_SKIP_CONVERT);
|
||||||
return;
|
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 itemWidth = item.bounds.width;
|
||||||
const itemHeight = item.bounds.height;
|
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)
|
item.translate(new paper.Point(ART_BOARD_WIDTH / 2, ART_BOARD_HEIGHT / 2)
|
||||||
.subtract(itemWidth, itemHeight));
|
.subtract(itemWidth, itemHeight));
|
||||||
}
|
}
|
||||||
paper.project.activeLayer.insertChild(0, item);
|
|
||||||
if (isGroup(item)) {
|
if (isGroup(item)) {
|
||||||
// Fixes an issue where we may export empty groups
|
// Fixes an issue where we may export empty groups
|
||||||
for (const child of item.children) {
|
for (const child of item.children) {
|
||||||
|
@ -229,7 +216,13 @@ class PaperCanvas extends React.Component {
|
||||||
}
|
}
|
||||||
ungroupItems([item]);
|
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) {
|
setCanvas (canvas) {
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
|
|
Loading…
Reference in a new issue