fix range selection when moving from right to left
This commit is contained in:
@@ -59,8 +59,14 @@ export class PlotViewComponent implements OnInit {
|
||||
}
|
||||
|
||||
positionInImage(event) : any {
|
||||
const x= event.offsetX;
|
||||
const y= event.offsetY;
|
||||
const rect = (<HTMLImageElement>document.getElementById('result-image')).getBoundingClientRect();
|
||||
const x= event.clientX - rect.left;
|
||||
const y= event.clientY - rect.top;
|
||||
|
||||
|
||||
//console.log("pos: " + x+"x" +y+ " rect: "+rect.x+"x"+rect.y + " client: "+ event.clientX+"x"+ event.clientY + " offset:" + event.offsetX+"x"+event.offsetY );
|
||||
console.log(JSON.stringify(rect));
|
||||
|
||||
|
||||
return {x: x, y: y};
|
||||
}
|
||||
@@ -104,17 +110,16 @@ export class PlotViewComponent implements OnInit {
|
||||
if (this.in_drag_mode && event.buttons == 1){
|
||||
const pos = this.positionInImage(event);
|
||||
|
||||
|
||||
this.drag_end_x = Math.max(Math.min(pos.x, this.imageWidth()-this.gnuplotRMargin), this.gnuplotLMargin);
|
||||
|
||||
const left = this.drag_start_x < this.drag_end_x ? this.drag_start_x : this.drag_end_x;
|
||||
const width = Math.abs(this.drag_start_x - this.drag_end_x);
|
||||
|
||||
if (width > 10) {
|
||||
//this.zoomInSliderStyle="position: absolute; left: "+left+"px; width: "+width+"px; top:"+this.gnuplotTMargin+"px; bottom: "+this.gnuplotBMargin+"px;";
|
||||
this.zoomInSliderStyleDisplay = "block";
|
||||
this.zoomInSliderStyleLeft= left+"px";
|
||||
this.zoomInSliderStyleWidth= width+"px";
|
||||
this.zoomInSliderStyleBottomMargin = "calc(100% - "+(this.imageHeight()-this.gnuplotBMargin)+"px)";
|
||||
} else {
|
||||
this.hideZoomInSlider();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user