mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
bug fixes
This commit is contained in:
parent
302228b8cd
commit
62fc655fd2
@ -175,7 +175,7 @@ function HistoryStateMoveTwoLayers(layer, oldIndex, newIndex) {
|
|||||||
saveHistoryState(this);
|
saveHistoryState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function HistoryStateMoveLayer(afterToDrop, toDrop, static, nMoved) {
|
function HistoryStateMoveLayer(afterToDrop, toDrop, staticc, nMoved) {
|
||||||
this.beforeToDrop = afterToDrop;
|
this.beforeToDrop = afterToDrop;
|
||||||
this.toDrop = toDrop;
|
this.toDrop = toDrop;
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ function HistoryStateMoveLayer(afterToDrop, toDrop, static, nMoved) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function() {
|
||||||
moveLayers(toDrop.menuEntry.id, static.menuEntry.id, true);
|
moveLayers(toDrop.menuEntry.id, staticc.menuEntry.id, true);
|
||||||
undoStates.push(this);
|
undoStates.push(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ function undo () {
|
|||||||
if (undoStates.length > 0) {
|
if (undoStates.length > 0) {
|
||||||
document.getElementById('redo-button').classList.remove('disabled');
|
document.getElementById('redo-button').classList.remove('disabled');
|
||||||
|
|
||||||
//get state
|
//get state
|
||||||
var undoState = undoStates[undoStates.length-1];
|
var undoState = undoStates[undoStates.length-1];
|
||||||
//console.log(undoState);
|
//console.log(undoState);
|
||||||
|
|
||||||
@ -387,9 +387,9 @@ function undo () {
|
|||||||
|
|
||||||
//restore the state
|
//restore the state
|
||||||
undoState.undo();
|
undoState.undo();
|
||||||
|
|
||||||
//if theres none left to undo, disable the option
|
//if theres none left to undo, disable the option
|
||||||
if (undoStates.length == 0)
|
if (undoStates.length == 0)
|
||||||
document.getElementById('undo-button').classList.add('disabled');
|
document.getElementById('undo-button').classList.add('disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ function redo () {
|
|||||||
//enable undo button
|
//enable undo button
|
||||||
document.getElementById('undo-button').classList.remove('disabled');
|
document.getElementById('undo-button').classList.remove('disabled');
|
||||||
|
|
||||||
//get state
|
//get state
|
||||||
var redoState = redoStates[redoStates.length-1];
|
var redoState = redoStates[redoStates.length-1];
|
||||||
|
|
||||||
//remove from redo array (do this before restoring the state, else the flatten state will break)
|
//remove from redo array (do this before restoring the state, else the flatten state will break)
|
||||||
@ -412,7 +412,7 @@ function redo () {
|
|||||||
redoState.redo();
|
redoState.redo();
|
||||||
|
|
||||||
//if theres none left to redo, disable the option
|
//if theres none left to redo, disable the option
|
||||||
if (redoStates.length == 0)
|
if (redoStates.length == 0)
|
||||||
document.getElementById('redo-button').classList.add('disabled');
|
document.getElementById('redo-button').classList.add('disabled');
|
||||||
}
|
}
|
||||||
//console.log(undoStates);
|
//console.log(undoStates);
|
||||||
|
10
js/_layer.js
10
js/_layer.js
@ -452,7 +452,7 @@ function renameLayer(event) {
|
|||||||
// Swaps two layer entries in the layer menu
|
// Swaps two layer entries in the layer menu
|
||||||
function moveLayers(toDropLayer, staticLayer, saveHistory = true) {
|
function moveLayers(toDropLayer, staticLayer, saveHistory = true) {
|
||||||
let toDrop = getLayerByID(toDropLayer);
|
let toDrop = getLayerByID(toDropLayer);
|
||||||
let static = getLayerByID(staticLayer);
|
let staticc = getLayerByID(staticLayer);
|
||||||
let layerCopy = layers.slice();
|
let layerCopy = layers.slice();
|
||||||
|
|
||||||
let beforeToDrop = toDrop.menuEntry.nextElementSibling;
|
let beforeToDrop = toDrop.menuEntry.nextElementSibling;
|
||||||
@ -461,9 +461,9 @@ function moveLayers(toDropLayer, staticLayer, saveHistory = true) {
|
|||||||
layerCopy.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1);
|
layerCopy.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1);
|
||||||
|
|
||||||
let toDropIndex = layerCopy.indexOf(toDrop);
|
let toDropIndex = layerCopy.indexOf(toDrop);
|
||||||
let staticIndex = layerCopy.indexOf(static);
|
let staticIndex = layerCopy.indexOf(staticc);
|
||||||
|
|
||||||
layerList.insertBefore(toDrop.menuEntry, static.menuEntry);
|
layerList.insertBefore(toDrop.menuEntry, staticc.menuEntry);
|
||||||
|
|
||||||
if (toDropIndex < staticIndex) {
|
if (toDropIndex < staticIndex) {
|
||||||
let tmp = toDrop.canvas.style.zIndex;
|
let tmp = toDrop.canvas.style.zIndex;
|
||||||
@ -488,7 +488,7 @@ function moveLayers(toDropLayer, staticLayer, saveHistory = true) {
|
|||||||
toDrop.canvas.style.zIndex = tmp;
|
toDrop.canvas.style.zIndex = tmp;
|
||||||
|
|
||||||
if (saveHistory) {
|
if (saveHistory) {
|
||||||
new HistoryStateMoveLayer(beforeToDrop, toDrop, static, nMoved);
|
new HistoryStateMoveLayer(beforeToDrop, toDrop, staticc, nMoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -515,7 +515,7 @@ function moveLayers(toDropLayer, staticLayer, saveHistory = true) {
|
|||||||
toDrop.canvas.style.zIndex = tmp;
|
toDrop.canvas.style.zIndex = tmp;
|
||||||
|
|
||||||
if (saveHistory) {
|
if (saveHistory) {
|
||||||
new HistoryStateMoveLayer(beforeToDrop, toDrop, static, nMoved);
|
new HistoryStateMoveLayer(beforeToDrop, toDrop, staticc, nMoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user