Skip to content

Commit 4ed0380

Browse files
authored
Respect fixedrange config of axes when pinch-zooming (#177)
1 parent d270125 commit 4ed0380

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/touch-controller.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ export class TouchController {
119119
async handleZoom(zoom: number) {
120120
const oldLayout = this.el.layout;
121121
const layout = {};
122-
123-
layout["xaxis.range"] = zoomedRange(oldLayout.xaxis, zoom);
124-
layout["yaxis.range"] = zoomedRange(oldLayout.yaxis, zoom);
125-
for (let i = 2; i < 31; i++) {
126-
layout[`xaxis${i}.range`] = zoomedRange(oldLayout[`xaxis${i}`], zoom);
127-
layout[`yaxis${i}.range`] = zoomedRange(oldLayout[`yaxis${i}`], zoom);
122+
const axes = Array.from({ length: 30 }).flatMap((_, i) => {
123+
const i_str = i === 0 ? "" : i + 1;
124+
return [`xaxis${i_str}`, `yaxis${i_str}`];
125+
});
126+
for (const axis of axes) {
127+
if (!oldLayout[axis]?.fixedrange) {
128+
layout[`${axis}.range`] = zoomedRange(oldLayout[axis], zoom);
129+
}
128130
}
129131
this.onZoom(layout);
130132
}

0 commit comments

Comments
 (0)