mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
6528c7724b
!! NOT STABLE !! Initial implementation. No UI update yet. Check js/model/Piskel.js and js/model/Layer.js for an overview of the new API. Piskels can be saved on the existing service. Previous piskels cannot be loaded. This should be fixed soon.
28 lines
836 B
JavaScript
28 lines
836 B
JavaScript
(function () {
|
|
var ns = $.namespace("pskl.service");
|
|
ns.HistoryService = function (piskelController) {
|
|
this.piskelController = piskelController;
|
|
};
|
|
|
|
ns.HistoryService.prototype.init = function () {
|
|
|
|
$.subscribe(Events.TOOL_RELEASED, this.saveState.bind(this));
|
|
$.subscribe(Events.UNDO, this.undo.bind(this));
|
|
$.subscribe(Events.REDO, this.redo.bind(this));
|
|
};
|
|
|
|
ns.HistoryService.prototype.saveState = function () {
|
|
this.piskelController.getCurrentFrame().saveState();
|
|
};
|
|
|
|
ns.HistoryService.prototype.undo = function () {
|
|
this.piskelController.getCurrentFrame().loadPreviousState();
|
|
$.publish(Events.FRAMESHEET_RESET);
|
|
};
|
|
|
|
ns.HistoryService.prototype.redo = function () {
|
|
this.piskelController.getCurrentFrame().loadNextState();
|
|
$.publish(Events.FRAMESHEET_RESET);
|
|
};
|
|
|
|
})(); |