mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Removed a few dependencies, refactored pixel-editor.js
This commit is contained in:
@ -9,6 +9,9 @@ const LayerList = (() => {
|
||||
Events.on("mousedown", layerList, openOptionsMenu);
|
||||
// Binding the add layer button to the right function
|
||||
Events.on('click',"add-layer-button", addLayer, false);
|
||||
// Listening to the switch mode event so I can change the layout
|
||||
Events.onCustom("switchedToAdvanced", showMenu);
|
||||
Events.onCustom("switchedToBasic", hideMenu);
|
||||
|
||||
// Making the layers list sortable
|
||||
new Sortable(layerList, {
|
||||
@ -19,6 +22,25 @@ const LayerList = (() => {
|
||||
onEnd: layerDragDrop
|
||||
});
|
||||
|
||||
function showMenu() {
|
||||
layerList.style.display = "inline-block";
|
||||
document.getElementById('layer-button').style.display = 'inline-block';
|
||||
}
|
||||
function hideMenu() {
|
||||
if (EditorState.documentCreated()) {
|
||||
if (!confirm('Switching to basic mode will flatten all the visible layers. Are you sure you want to continue?')) {
|
||||
return;
|
||||
}
|
||||
// Selecting the current layer
|
||||
currFile.currentLayer.selectLayer();
|
||||
// Flatten the layers
|
||||
flatten(true);
|
||||
}
|
||||
|
||||
layerList.style.display = "none";
|
||||
document.getElementById('layer-button').style.display = 'none';
|
||||
}
|
||||
|
||||
function addLayer(id, saveHistory = true) {
|
||||
// layers.length - 3
|
||||
let index = currFile.layers.length - 3;
|
||||
|
Reference in New Issue
Block a user