Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
feat: migrate to latest anywidget
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Jul 7, 2023
1 parent ae7309e commit a95bdba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions higlass_widget/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ function toPts({ xDomain, yDomain }) {
return [x, xe, y, ye];
}

export async function render(view) {
let viewconf = JSON.parse(view.model.get("_viewconf"));
let api = await hglib.viewer(view.el, viewconf);
export async function render({ model, el }) {
let viewconf = JSON.parse(model.get("_viewconf"));
let api = await hglib.viewer(el, viewconf);

view.model.on("msg:custom", (msg) => {
model.on("msg:custom", (msg) => {
msg = JSON.parse(msg);
let [fn, ...args] = msg;
api[fn](...args);
});

if (viewconf.views.length === 1) {
api.on("location", (loc) => {
view.model.set("location", toPts(loc));
view.model.save_changes();
model.set("location", toPts(loc));
model.save_changes();
}, viewconf.views[0].uid);
} else {
viewconf.views.forEach((view, idx) => {
viewconf.views.forEach((_view, idx) => {
api.on("location", (loc) => {
let copy = view.model.get("location").slice();
let copy = model.get("location").slice();
copy[idx] = toPts(loc);
view.model.set("location", copy);
view.model.save_changes();
}, view.uid);
model.set("location", copy);
model.save_changes();
}, uid);
});
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dynamic = ["version"]
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"anywidget>=0.3",
"anywidget>=0.6",
]

[project.optional-dependencies]
Expand Down

0 comments on commit a95bdba

Please sign in to comment.