From e39f996682d9555252c361636d955c7bad43364f Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Tue, 30 Jul 2024 16:26:46 +0200 Subject: [PATCH] :bug: Fix WCS recovering when widget is out of sight --- js/models/event_handler.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/js/models/event_handler.js b/js/models/event_handler.js index 6bfd84f6..ebeb9af9 100644 --- a/js/models/event_handler.js +++ b/js/models/event_handler.js @@ -129,6 +129,13 @@ export default class EventHandler { this.aladin.setFoV(fov); }); + this.aladin.on("layerChanged", (imageLayer, layerName, state) => { + if (layerName !== "base" || state !== "ADDED") return; + this.updateWCS(); + this.model.set("_base_layer_last_view", imageLayer.id); + this.model.save_changes(); + }); + /* Div control */ this.model.on("change:_height", () => { let height = this.model.get("_height"); @@ -151,16 +158,12 @@ export default class EventHandler { this.model.save_changes(); }); - this.aladin.on("layerChanged", (imageLayer, layerName, state) => { - if (layerName !== "base" || state !== "ADDED") return; - this.updateWCS(); - this.model.set("_base_layer_last_view", imageLayer.id); - this.model.save_changes(); - }); - - this.aladin.on("resizeChanged", () => { + this.aladin.on("resizeChanged", (width, height) => { + // Skip resize event when the div is hidden + if (width === 1 && height === 1) return; this.updateWCS(); this.update2AxisFoV(); + this.model.set("_height", height); this.model.save_changes(); });