Skip to content

Commit

Permalink
🐛 Fix multi-instances flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Apr 17, 2024
1 parent c9cbc40 commit c229db9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions js/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,27 @@ function render({ model, el }) {
// listeners from triggering each other and creating a buggy loop. The same trick
// is also necessary for the field of view.

let target_lock = false;
let target_js = false;
let target_py = false;

aladin.on("positionChanged", () => {
target_lock = true;
if (target_py) {
target_py = false;
return;
}
target_js = true;
const ra_dec = aladin.getRaDec();
model.set("_target", `${ra_dec[0]} ${ra_dec[1]}`);
model.set("shared_target", `${ra_dec[0]} ${ra_dec[1]}`);
model.save_changes();
});

model.on("change:shared_target", () => {
if (target_lock) {
target_lock = false;
if (target_js) {
target_js = false;
return;
}
target_py = true;
const target = model.get("shared_target");
const [ra, dec] = target.split(" ");
aladin.gotoRaDec(ra, dec);
Expand Down

0 comments on commit c229db9

Please sign in to comment.