diff --git a/catview.js b/catview.js index 5e4b62ab3dbb6bb6e43c728c51e9addf39d48a4b..352c71769e446600391948d78e891ff509d638af 100644 --- a/catview.js +++ b/catview.js @@ -936,7 +936,8 @@ const CATview = new function() { if(CATview.content){ CATview.set_margins(); - CATview.set_scale_x(); + CATview.set_scale_x(0, CATview.edges.length + 1); + CATview.scale_edges_original = CATview.scale_edges.copy(); // relocate the content container CATview.svg.select(".content").attr("transform", "translate(" + CATview.margin.left + "," + CATview.margin.top + ")"); CATview.draw_zebra_stripes(); @@ -991,8 +992,6 @@ const CATview = new function() { let new_scale = d3.event.transform.k; let new_translate = CATview.vertical == true ? (d3.event.transform.y/new_scale) : (d3.event.transform.x/new_scale); - if(CATview.x_inverted) - new_translate = -new_translate; if(CATview.content){ @@ -1039,10 +1038,14 @@ const CATview = new function() { CATview.translate = new_translate; CATview.scale = new_scale; - // calculate the edges within this new zoom let new_from = Math.ceil(CATview.scale_edges_original.invert(new_from_pixel)); let new_to = Math.floor(CATview.scale_edges_original.invert(new_to_pixel)); + if(CATview.x_inverted){ + let swap = new_from; + new_from = new_to; + new_to = swap; + } if(new_from != CATview.from || new_to != CATview.to) { // refresh the content only if edges within the new zoom have changed CATview.refresh_content(new_from, new_to);