@leapfrog/interactive-canvas 1.11.0 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,6 @@ import { AbstractInteractiveCanvas } from "./abstract-interactive-canvas";
|
|
|
2
2
|
export declare class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
3
3
|
protected devicePixelRatio: number;
|
|
4
4
|
private readonly undoStack;
|
|
5
|
-
private undoSub;
|
|
6
5
|
constructor(elementId: string, devicePixelRatio: number);
|
|
7
6
|
/**
|
|
8
7
|
* @override
|
|
@@ -3649,11 +3649,8 @@ var UndoStack = /** @class */ (function () {
|
|
|
3649
3649
|
}
|
|
3650
3650
|
UndoStack.prototype.push = function (state) {
|
|
3651
3651
|
var prev = this.stack[this.stack.length - 1];
|
|
3652
|
-
if (isEqual(prev, state))
|
|
3653
|
-
console.error("Ignoring identical undo state"); //todo
|
|
3652
|
+
if (isEqual(prev, state))
|
|
3654
3653
|
return;
|
|
3655
|
-
}
|
|
3656
|
-
console.error("Undo Registered"); //todo
|
|
3657
3654
|
this.stack.push(state);
|
|
3658
3655
|
if (this.stack.length > this.size)
|
|
3659
3656
|
this.stack.splice(0, 1);
|
|
@@ -3669,7 +3666,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3669
3666
|
function InteractiveCanvas(elementId, devicePixelRatio) {
|
|
3670
3667
|
var _this = _super.call(this, window['fabric'], new window['fabric'].Canvas(elementId), devicePixelRatio) || this;
|
|
3671
3668
|
_this.devicePixelRatio = devicePixelRatio;
|
|
3672
|
-
_this.undoStack = new UndoStack(
|
|
3669
|
+
_this.undoStack = new UndoStack(100);
|
|
3673
3670
|
//Initialize watchers
|
|
3674
3671
|
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3675
3672
|
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
@@ -3699,6 +3696,12 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3699
3696
|
state = this.undoStack.pop();
|
|
3700
3697
|
if (!state)
|
|
3701
3698
|
return [2 /*return*/];
|
|
3699
|
+
//If the undo state matches the current state, pop again as the undo will have no effect
|
|
3700
|
+
if (isEqual(state, this.save())) {
|
|
3701
|
+
state = this.undoStack.pop();
|
|
3702
|
+
if (!state)
|
|
3703
|
+
return [2 /*return*/];
|
|
3704
|
+
}
|
|
3702
3705
|
return [4 /*yield*/, this.load(state)];
|
|
3703
3706
|
case 1:
|
|
3704
3707
|
_a.sent();
|
|
@@ -3649,11 +3649,8 @@ var UndoStack = /** @class */ (function () {
|
|
|
3649
3649
|
}
|
|
3650
3650
|
UndoStack.prototype.push = function (state) {
|
|
3651
3651
|
var prev = this.stack[this.stack.length - 1];
|
|
3652
|
-
if (_.isEqual(prev, state))
|
|
3653
|
-
console.error("Ignoring identical undo state"); //todo
|
|
3652
|
+
if (_.isEqual(prev, state))
|
|
3654
3653
|
return;
|
|
3655
|
-
}
|
|
3656
|
-
console.error("Undo Registered"); //todo
|
|
3657
3654
|
this.stack.push(state);
|
|
3658
3655
|
if (this.stack.length > this.size)
|
|
3659
3656
|
this.stack.splice(0, 1);
|
|
@@ -3669,7 +3666,7 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3669
3666
|
function InteractiveCanvas(elementId, devicePixelRatio) {
|
|
3670
3667
|
var _this = _super.call(this, window['fabric'], new window['fabric'].Canvas(elementId), devicePixelRatio) || this;
|
|
3671
3668
|
_this.devicePixelRatio = devicePixelRatio;
|
|
3672
|
-
_this.undoStack = new UndoStack(
|
|
3669
|
+
_this.undoStack = new UndoStack(100);
|
|
3673
3670
|
//Initialize watchers
|
|
3674
3671
|
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3675
3672
|
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
@@ -3699,6 +3696,12 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3699
3696
|
state = this.undoStack.pop();
|
|
3700
3697
|
if (!state)
|
|
3701
3698
|
return [2 /*return*/];
|
|
3699
|
+
//If the undo state matches the current state, pop again as the undo will have no effect
|
|
3700
|
+
if (_.isEqual(state, this.save())) {
|
|
3701
|
+
state = this.undoStack.pop();
|
|
3702
|
+
if (!state)
|
|
3703
|
+
return [2 /*return*/];
|
|
3704
|
+
}
|
|
3702
3705
|
return [4 /*yield*/, this.load(state)];
|
|
3703
3706
|
case 1:
|
|
3704
3707
|
_a.sent();
|