Skip to content

Commit 0abe14a

Browse files
committed
Update yValue when shift+scrolling
1 parent 3172d43 commit 0abe14a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

client/src/components/geoJS/layers/measureToolLayer.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,16 @@ export default class MeasureToolLayer extends BaseTextLayer<TextData> {
202202
}
203203
}
204204

205-
setScaledDimensions(width: number, height: number) {
206-
super.setScaledDimensions(width, height);
205+
setScaledDimensions(scaledWidth: number, scaledHeight: number) {
206+
// Get the frequency represented by the current ruler
207+
const height = Math.max(this.scaledHeight, this.spectroInfo.height);
208+
const frequency = height - this.yValue >= 0
209+
? ((height - this.yValue) * (this.spectroInfo.high_freq - this.spectroInfo.low_freq)) / height / 1000 + this.spectroInfo.low_freq / 1000
210+
: -1;
211+
// Get the new yValue needed based on the updated scaled height
212+
const newY = scaledHeight - ((frequency - (this.spectroInfo.low_freq / 1000)) * scaledHeight * 1000) / (this.spectroInfo.high_freq - this.spectroInfo.low_freq);
213+
this.yValue = newY;
214+
super.setScaledDimensions(scaledWidth, scaledHeight);
207215
this.clearRulerLayer();
208216
if (this.rulerOn) {
209217
this.enableDrawing();

0 commit comments

Comments
 (0)