diff --git a/bin/em/variabletime/web/js/artboard.js b/bin/em/variabletime/web/js/artboard.js index 065f091..6638c30 100644 --- a/bin/em/variabletime/web/js/artboard.js +++ b/bin/em/variabletime/web/js/artboard.js @@ -173,6 +173,35 @@ const Artboard = function(tp, domElement = false, autoInit = true) { this.hide = () => { // nothing to do }; + const getHierarchyPanelButton = () => { + if (hierarchyPanelButton === null) { + hierarchyPanelButton = tp.shadowRoot.querySelector(`.layerMover${this.id()}`); + } + return hierarchyPanelButton; + }; + this.isSelected = () => { + const panel = getHierarchyPanelButton(); + if (panel === null) { + return false; + } else { + const notSelected = panel.querySelector('.not-selected'); + return !notSelected; + } + }; + this.select = () => { + const panel = getHierarchyPanelButton(); + const selectables = panel.querySelector('.not-selected'); + if (selectables !== null && typeof selectables.dispatchEvent === 'function') { + var clickEvent = new MouseEvent("click", { + "view": window, + "bubbles": true, + "cancelable": false + }); + selectables.dispatchEvent(clickEvent); + } else { + window.debugElement = panel; + } + }; // action if (typeof domElement !== 'object') { diff --git a/bin/em/variabletime/web/js/main.js b/bin/em/variabletime/web/js/main.js index 95d8617..8268145 100644 --- a/bin/em/variabletime/web/js/main.js +++ b/bin/em/variabletime/web/js/main.js @@ -121,10 +121,7 @@ window.showAbout = () => { if (getAbout() === null) { return; } - getAbout().classList.remove("hidden"); - - } window.hideAbout = () => { if (getAbout() !== null) { @@ -524,9 +521,19 @@ const deleteLayer = (id, saveProject = true) => { } }); } + const wasSelected = layers[index].isSelected(); layers[index].prepareForDepartureFromThisBeautifulExperience(); layers.splice(index, 1); delete layersById[id]; + if (wasSelected) { + if (layers.length > index + 1) { + layers[index].select(); + } else if (layers.length > 0) { + layers[layers.length - 1].select(); + } else { + artboard.select(); + } + } if (saveProject) { setTimeout(() => { tp.saveProject();