diff --git a/pdb-js/src/app/plot-view/plot-view.component.ts b/pdb-js/src/app/plot-view/plot-view.component.ts index 1c0d9b4..e220aff 100644 --- a/pdb-js/src/app/plot-view/plot-view.component.ts +++ b/pdb-js/src/app/plot-view/plot-view.component.ts @@ -59,8 +59,14 @@ export class PlotViewComponent implements OnInit { } positionInImage(event) : any { - const x= event.offsetX; - const y= event.offsetY; + const rect = (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}; } @@ -103,7 +109,6 @@ 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); @@ -111,10 +116,10 @@ export class PlotViewComponent implements OnInit { 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(); }