mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Selection Manager : fix undo/redo regression
This commit is contained in:
parent
4e1f6bee3f
commit
ff98670055
@ -95,12 +95,7 @@
|
||||
var pixels = this.currentSelection.pixels;
|
||||
var frame = this.piskelController.getCurrentFrame();
|
||||
|
||||
pixels.forEach(function (pixel) {
|
||||
if (pixel.color === Constants.TRANSPARENT_COLOR || pixel.color === null) {
|
||||
return;
|
||||
}
|
||||
frame.setPixel(pixel.col, pixel.row, pixel.color);
|
||||
});
|
||||
this.pastePixels_(frame, pixels);
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : pskl.service.HistoryService.REPLAY,
|
||||
@ -113,9 +108,21 @@
|
||||
};
|
||||
|
||||
ns.SelectionManager.prototype.replay = function (frame, replayData) {
|
||||
if (replayData.type === SELECTION_REPLAY.PASTE) {
|
||||
this.pastePixels_(frame, replayData.pixels);
|
||||
} else if (replayData.type === SELECTION_REPLAY.ERASE) {
|
||||
replayData.pixels.forEach(function (pixel) {
|
||||
var color = replayData.type === SELECTION_REPLAY.PASTE ? pixel.color : Constants.TRANSPARENT_COLOR;
|
||||
frame.setPixel(pixel.col, pixel.row, color);
|
||||
frame.setPixel(pixel.col, pixel.row, Constants.TRANSPARENT_COLOR);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ns.SelectionManager.prototype.pastePixels_ = function(frame, pixels) {
|
||||
pixels.forEach(function (pixel) {
|
||||
if (pixel.color === Constants.TRANSPARENT_COLOR || pixel.color === null) {
|
||||
return;
|
||||
}
|
||||
frame.setPixel(pixel.col, pixel.row, pixel.color);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user