From 3ef8d4e5e3aa76ec572781ad757503c2f8786f63 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 6 Mar 2016 09:07:05 +0000 Subject: [PATCH] Open editor as part of setEditorData() Also add a smooth transition between open and closed states. --- src/gui/html/elements/loot-plugin-editor.html | 19 +++++++++++++++++-- src/gui/html/index.html | 2 +- src/gui/html/js/events.js | 9 +-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/gui/html/elements/loot-plugin-editor.html b/src/gui/html/elements/loot-plugin-editor.html index b5d26c4b..48c9c1a6 100644 --- a/src/gui/html/elements/loot-plugin-editor.html +++ b/src/gui/html/elements/loot-plugin-editor.html @@ -32,6 +32,14 @@ loot-editor-close height: 264px; min-height: 56px; max-height: calc(100% - 56px); + transition: height 0.6s, min-height 0.6s; + } + :host(.hidden) { + height: 0; + min-height: 0; + } + :host(.resizing) { + transition: unset; } /* Material Design for non-button icons. */ @@ -240,7 +248,10 @@ loot-editor-close _onSplitterDrag(evt) { if (evt.detail.state === 'start') { + this.parentNode.host.classList.toggle('resizing', true); this.parentNode.host.style.height = parseInt(window.getComputedStyle(this.parentNode.host).height, 10) + 'px'; + } else if (evt.detail.state === 'end') { + this.parentNode.host.classList.toggle('resizing', false); } this.parentNode.host.style.height = (parseInt(this.parentNode.host.style.height, 10) - evt.detail.ddy) + 'px'; }, @@ -327,8 +338,9 @@ loot-editor-close } if (isValid || evt.target.id !== 'accept') { - /* Reset height to default */ - this.parentElement.parentNode.host.style.height = '264px'; + /* Now hide editor. */ + evt.target.parentElement.parentNode.host.style.height = ''; + evt.target.parentElement.parentNode.host.classList.toggle('hidden', true); /* Fire the close event, saying whether or not to save data. */ evt.target.dispatchEvent(new CustomEvent('loot-editor-close', { @@ -424,6 +436,9 @@ loot-editor-close } } } + + /* Now show editor. */ + this.classList.toggle('hidden', false); }, }); diff --git a/src/gui/html/index.html b/src/gui/html/index.html index ce053577..429dbdd3 100644 --- a/src/gui/html/index.html +++ b/src/gui/html/index.html @@ -335,7 +335,7 @@ -