From f7eb3647fdfb3241e099a56e14184594c72050d8 Mon Sep 17 00:00:00 2001 From: JFH <20402845+jfhenon@users.noreply.github.com> Date: Sat, 9 Jan 2021 23:51:11 +0100 Subject: [PATCH] fix #66 --- src/editor/components/seFlyingButton.js | 39 +++++++- src/editor/components/seSpinInput.js | 2 +- src/editor/svgedit.css | 121 ++++++++++-------------- src/editor/svgedit.js | 2 +- 4 files changed, 87 insertions(+), 77 deletions(-) diff --git a/src/editor/components/seFlyingButton.js b/src/editor/components/seFlyingButton.js index 1a93fa3a0..07926aa4b 100644 --- a/src/editor/components/seFlyingButton.js +++ b/src/editor/components/seFlyingButton.js @@ -107,7 +107,7 @@ export class FlyingButton extends HTMLElement { * @returns {any} observed */ static get observedAttributes () { - return ['title', 'pressed', 'disabled']; + return ['title', 'pressed', 'disabled', 'opened']; } /** * @function attributeChangedCallback @@ -132,6 +132,13 @@ export class FlyingButton extends HTMLElement { this.$overall.classList.remove('pressed'); } break; + case 'opened': + if (newValue) { + this.$menu.classList.add('open'); + } else { + this.$menu.classList.remove('open'); + } + break; case 'disabled': if (newValue) { this.$div.classList.add('disabled'); @@ -178,6 +185,28 @@ export class FlyingButton extends HTMLElement { this.setAttribute('pressed', 'true'); } else { this.removeAttribute('pressed', ''); + // close also the menu if open + this.removeAttribute('opened'); + } + } + /** + * @function get + * @returns {any} + */ + get opened () { + return this.hasAttribute('opened'); + } + + /** + * @function set + * @returns {void} + */ + set opened (value) { + // boolean value => existence = true + if (value) { + this.setAttribute('opened', 'opened'); + } else { + this.removeAttribute('opened'); } } /** @@ -214,7 +243,7 @@ export class FlyingButton extends HTMLElement { switch (ev.target.nodeName) { case 'SE-FLYINGBUTTON': if (this.pressed) { - this.$menu.classList.toggle('open'); + this.setAttribute('opened', 'opened'); } else { // launch current action this.activeSlot.click(); @@ -231,7 +260,11 @@ export class FlyingButton extends HTMLElement { break; case 'DIV': // this is a click on the handle so let's open/close the menu. - this.$menu.classList.toggle('open'); + if (this.opened) { + this.removeAttribute('opened'); + } else { + this.setAttribute('opened', 'opened'); + } break; default: // eslint-disable-next-line no-console diff --git a/src/editor/components/seSpinInput.js b/src/editor/components/seSpinInput.js index 1782865c5..267fe145c 100644 --- a/src/editor/components/seSpinInput.js +++ b/src/editor/components/seSpinInput.js @@ -6,7 +6,7 @@ template.innerHTML = `