diff --git a/examples/al-disto.html b/examples/al-disto.html new file mode 100644 index 00000000..3912d034 --- /dev/null +++ b/examples/al-disto.html @@ -0,0 +1,19 @@ + + + + + + +
+ + + + + diff --git a/src/js/Aladin.js b/src/js/Aladin.js index c10a7fb8..34d63006 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -737,8 +737,6 @@ export let Aladin = (function () { } }) - //this.fullScreenBtn.attr('title', isInFullscreen ? 'Restore original size' : 'Full screen'); - if (this.aladinDiv.classList.contains("aladin-fullscreen")) { this.aladinDiv.classList.remove("aladin-fullscreen"); } else { @@ -788,6 +786,8 @@ export let Aladin = (function () { self.callbacksByEventName["fullScreenToggled"]; typeof fullScreenToggledFn === "function" && fullScreenToggledFn(self.isInFullscreen); + + ALEvent.FULLSCREEN_TOGGLED.dispatchedTo(this.aladinDiv, {fullscreen: self.isInFullscreen}); }; Aladin.prototype.getOptionsFromQueryString = function () { diff --git a/src/js/FiniteStateMachine/CircleSelect.js b/src/js/FiniteStateMachine/CircleSelect.js index 7517cccd..a66e0119 100644 --- a/src/js/FiniteStateMachine/CircleSelect.js +++ b/src/js/FiniteStateMachine/CircleSelect.js @@ -118,7 +118,11 @@ export class CircleSelect extends FSM { this.dispatch("off"); }; - let mouseout = mouseup; + let mouseout = (params) => { + if (this.startCoo) { + mouseup(params); + } + }; let off = () => { view.aladin.showReticle(true) @@ -153,7 +157,8 @@ export class CircleSelect extends FSM { mouseout }, mouseout: { - off + off, + mousedown }, mouseup: { off, diff --git a/src/js/FiniteStateMachine/RectSelect.js b/src/js/FiniteStateMachine/RectSelect.js index d93640d2..608b47af 100644 --- a/src/js/FiniteStateMachine/RectSelect.js +++ b/src/js/FiniteStateMachine/RectSelect.js @@ -74,6 +74,7 @@ export class RectSelect extends FSM { let mouseup = (params) => { var x, y; const {coo} = params; + this.coo = coo; // finish the selection var w = this.coo.x - this.startCoo.x; @@ -132,7 +133,11 @@ export class RectSelect extends FSM { view.aladin.removeStatusBarMessage('selector') } - let mouseout = mouseup; + let mouseout = (params) => { + if (this.startCoo) { + mouseup(params); + } + }; super({ state: 'off', @@ -163,7 +168,8 @@ export class RectSelect extends FSM { off }, mouseout: { - off + off, + mousedown }, mouseup: { off, diff --git a/src/js/Selector.js b/src/js/Selector.js index 99a191be..2123d9c8 100644 --- a/src/js/Selector.js +++ b/src/js/Selector.js @@ -91,7 +91,7 @@ export class Selector { } cancel() { - this.dispatch('off') + this.select && this.dispatch('off') } dispatch(to, params) { diff --git a/src/js/View.js b/src/js/View.js index cb5ca885..edcf1f5e 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -1258,7 +1258,13 @@ export let View = (function () { break; // escape case 27: - view.selector.cancel() + // if there is a selection occuring + view.selector && view.selector.cancel() + + if (view.aladin.isInFullscreen) { + view.aladin.toggleFullscreen(view.aladin.options.realFullscreen); + } + break; default: break; diff --git a/src/js/events/ALEvent.js b/src/js/events/ALEvent.js index 46dd350e..40d12ec7 100644 --- a/src/js/events/ALEvent.js +++ b/src/js/events/ALEvent.js @@ -79,6 +79,8 @@ export class ALEvent { static MODE = new ALEvent("AL:mode") + static FULLSCREEN_TOGGLED = new ALEvent("AL:fullscreen.toggled") + constructor(name) { this.name = name; } diff --git a/src/js/gui/Button/FullScreen.js b/src/js/gui/Button/FullScreen.js index 482ca115..d309be2c 100644 --- a/src/js/gui/Button/FullScreen.js +++ b/src/js/gui/Button/FullScreen.js @@ -29,6 +29,8 @@ *****************************************************************************/ import { ActionButton } from "../Widgets/ActionButton.js"; +import { ALEvent } from "../../events/ALEvent"; + import restoreIcon from './../../../../assets/icons/restore.svg'; import maximizeIcon from './../../../../assets/icons/maximize.svg'; @@ -57,39 +59,44 @@ export class FullScreenActionButton extends ActionButton { } aladin.toggleFullscreen(aladin.options.realFullscreen); - - if (aladin.isInFullscreen) { - self.update({ - icon: { - size: 'medium', - monochrome: true, - url: restoreIcon - }, - tooltip: { - content: 'Restore original size', - position: { - direction: 'left' - } - } - }); - } else { - self.update({ - icon: { - size: 'medium', - monochrome: true, - url: maximizeIcon - }, - tooltip: { - content: 'Fullscreen', - position: { - direction: 'left' - } - } - }); - } } }) self = this; + + // Listen to the fullscreen toggled event to change the icon of the button + ALEvent.FULLSCREEN_TOGGLED.listenedBy(aladin.aladinDiv, (event) => { + const isInFullscreen = event.detail.fullscreen; + + if (isInFullscreen) { + self.update({ + icon: { + size: 'medium', + monochrome: true, + url: restoreIcon + }, + tooltip: { + content: 'Restore original size', + position: { + direction: 'left' + } + } + }); + } else { + self.update({ + icon: { + size: 'medium', + monochrome: true, + url: maximizeIcon + }, + tooltip: { + content: 'Fullscreen', + position: { + direction: 'left' + } + } + }); + } + }); } } \ No newline at end of file diff --git a/src/js/gui/Widgets/Widget.js b/src/js/gui/Widgets/Widget.js index a9da7a23..74823e24 100644 --- a/src/js/gui/Widgets/Widget.js +++ b/src/js/gui/Widgets/Widget.js @@ -74,7 +74,6 @@ export class DOMElement { if (target && target.children) { index = Array.prototype.indexOf.call(target.children, el); } - console.log("remove", el) el.remove() return {target, position: index};