fix undo removes cursor preview

This commit is contained in:
DD 2017-10-11 17:17:19 -04:00
parent 4d9ecb2a2c
commit affe8463be
4 changed files with 7 additions and 3 deletions

View file

@ -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();
}

View file

@ -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';

View file

@ -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++) {

View file

@ -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();