Skip to content

Commit ad8eb98

Browse files
actually fix drag rezoom
1 parent 449c257 commit ad8eb98

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/index.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6802,7 +6802,32 @@ export class ULabel {
68026802
this.drag_state["zoom"]["mouse_start"][0],
68036803
this.drag_state["zoom"]["mouse_start"][1],
68046804
);
6805-
this.rezoom(foc.x, foc.y);
6805+
6806+
// Compute scroll from the drag-start baseline
6807+
const annbox = $("#" + this.config["annbox_id"]);
6808+
6809+
const new_width = Math.round(this.config["image_width"] * this.state["zoom_val"]);
6810+
const new_height = Math.round(this.config["image_height"] * this.state["zoom_val"]);
6811+
6812+
// Resize
6813+
var toresize = $("." + this.config["imgsz_class"]);
6814+
toresize.css("width", new_width + "px");
6815+
toresize.css("height", new_height + "px");
6816+
this.filter_distance_overlay?.resize_canvas(new_width, new_height);
6817+
this.resize_active_polygon_ender();
6818+
6819+
// Scroll from drag-start baseline
6820+
const start_width = this.config["image_width"] * this.drag_state["zoom"]["zoom_val_start"];
6821+
const start_height = this.config["image_height"] * this.drag_state["zoom"]["zoom_val_start"];
6822+
const old_left = this.drag_state["zoom"]["offset_start"][0];
6823+
const old_top = this.drag_state["zoom"]["offset_start"][1];
6824+
annbox.scrollLeft((old_left + foc.x) * new_width / start_width - foc.x);
6825+
annbox.scrollTop((old_top + foc.y) * new_height / start_height - foc.y);
6826+
6827+
this.redraw_demo();
6828+
if (this.state.anno_scaling_mode === "inverse-zoom" || this.state.anno_scaling_mode === "match-zoom") {
6829+
this.redraw_all_annotations();
6830+
}
68066831
}
68076832

68086833
// Set the zoom value in state and render accordingly

0 commit comments

Comments
 (0)