mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 13:32:28 -05:00
fix undo removes cursor preview
This commit is contained in:
parent
4d9ecb2a2c
commit
affe8463be
4 changed files with 7 additions and 3 deletions
|
@ -4,6 +4,7 @@ import BroadBrushHelper from './broad-brush-helper';
|
|||
import SegmentBrushHelper from './segment-brush-helper';
|
||||
import {MIXED, styleCursorPreview} from '../../helper/style-path';
|
||||
import {clearSelection} from '../../helper/selection';
|
||||
import {getGuideLayer} from '../../helper/layer';
|
||||
|
||||
/**
|
||||
* Shared code for the brush and eraser mode. Adds functions on the paper tool object
|
||||
|
@ -166,7 +167,7 @@ class Blobbiness {
|
|||
this.cursorPreviewLastPoint = point;
|
||||
}
|
||||
|
||||
if (this.cursorPreview &&
|
||||
if (this.cursorPreview && this.cursorPreview.parent &&
|
||||
this.brushSize === this.options.brushSize &&
|
||||
this.fillColor === this.options.fillColor &&
|
||||
this.strokeColor === this.options.strokeColor) {
|
||||
|
@ -176,6 +177,8 @@ class Blobbiness {
|
|||
center: point,
|
||||
radius: this.options.brushSize / 2
|
||||
});
|
||||
newPreview.parent = getGuideLayer();
|
||||
newPreview.data.isHelperItem = true;
|
||||
if (this.cursorPreview) {
|
||||
this.cursorPreview.remove();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import React from 'react';
|
|||
import {connect} from 'react-redux';
|
||||
import bindAll from 'lodash.bindall';
|
||||
import Modes from '../modes/modes';
|
||||
import {changeStrokeWidth} from '../reducers/stroke-width';
|
||||
import {clearSelection, getSelectedLeafItems} from '../helper/selection';
|
||||
import {MIXED} from '../helper/style-path';
|
||||
import {changeMode} from '../reducers/modes';
|
||||
|
|
|
@ -178,7 +178,6 @@ const _deleteItemSelection = function (items, onUpdateSvg) {
|
|||
};
|
||||
|
||||
const _removeSelectedSegments = function (items, onUpdateSvg) {
|
||||
performSnapshot(undoSnapshot);
|
||||
const segmentsToRemove = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
|
|
@ -12,6 +12,9 @@ const performSnapshot = function (dispatchPerformSnapshot) {
|
|||
};
|
||||
|
||||
const _restore = function (entry, onUpdateSvg) {
|
||||
for (const layer of paper.project.layers) {
|
||||
layer.removeChildren();
|
||||
}
|
||||
paper.project.clear();
|
||||
paper.project.importJSON(entry.json);
|
||||
paper.view.update();
|
||||
|
|
Loading…
Reference in a new issue