Skip to content

Commit

Permalink
Working version without shared_target traitlets
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed May 6, 2024
1 parent 13d8417 commit 3525b60
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions js/models/event_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,21 @@ export default class EventHandler {

// Event triggered when the user moves the map in Aladin Lite
this.aladin.on("positionChanged", (position) => {
if (f1Lock.locked) return;
// const raDec = this.aladin.getRaDec();
const raDec = [position.ra, position.dec];
this.clog("positionChanged", `${raDec[0]} ${raDec[1]}`);
if (f1Lock.locked) {
f1Lock.unlock();
return;
}
const raDec = this.aladin.getRaDec();
// const raDec = [position.ra, position.dec];
this.model.set("_target", `${raDec[0]} ${raDec[1]}`);
this.model.set("shared_target", `${raDec[0]} ${raDec[1]}`);
this.model.save_changes();
f2Lock.unlock();
});

// Event triggered when the target is changed from the Python side using jslink
this.model.on("change:shared_target", () => {
if (f1Lock.locked) return;
f2Lock.lock();
const target = this.model.get("shared_target");
const [ra, dec] = target.split(" ");
this.clog("change:shared_target", target);
this.model.on("change:_target", () => {
const [ra, dec] = this.model.get("_target").split(" ");
this.aladin.gotoRaDec(ra, dec);
f1Lock.unlock();
f1Lock.lock();
});

/* Field of View control */
Expand Down

0 comments on commit 3525b60

Please sign in to comment.