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(); });