restrict zoomin via drag'n'drop to the zoomable area
Fixed issues that not the whole area was selected when moving the cursor too fast out of the selectable area.
This commit is contained in:
@@ -223,10 +223,14 @@ Vue.component('result-view', {
|
||||
plotCurrent();
|
||||
}
|
||||
},
|
||||
hideZoomInSlider: function (){
|
||||
this.zoomInSliderStyle="display: none;";
|
||||
},
|
||||
imageWidth: function() {
|
||||
return Math.floor($('#result').width());
|
||||
},
|
||||
isInPlot: function(x){
|
||||
|
||||
const imageWith = Math.floor($('#result').width());
|
||||
return x > gnuplotLMargin && x < imageWith - gnuplotRMargin;
|
||||
return x > gnuplotLMargin && x < this.imageWidth() - gnuplotRMargin;
|
||||
},
|
||||
drag_start: function(event) {
|
||||
event.preventDefault();
|
||||
@@ -238,19 +242,23 @@ Vue.component('result-view', {
|
||||
},
|
||||
dragging: function(event) {
|
||||
|
||||
if (this.in_drag_mode && event.buttons == 1 && this.isInPlot(event.x) && !data.searchBar.imageLastUsedParams.keyOutside){
|
||||
this.drag_end_x = event.x;
|
||||
if (this.in_drag_mode && event.buttons == 1 && !data.searchBar.imageLastUsedParams.keyOutside){
|
||||
this.drag_end_x = Math.max(Math.min(event.x, this.imageWidth()-gnuplotRMargin), 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:"+gnuplotTMargin+"px; bottom: "+gnuplotBMargin+"px;";
|
||||
} else {
|
||||
this.hideZoomInSlider();
|
||||
}
|
||||
}
|
||||
},
|
||||
drag_stop: function(event) {
|
||||
if (this.in_drag_mode && !data.searchBar.imageLastUsedParams.keyOutside){
|
||||
this.in_drag_mode = false;
|
||||
this.zoomInSliderStyle="display: none;";
|
||||
this.hideZoomInSlider();
|
||||
|
||||
// Zoom in if the selected area has some arbitrary minimal size
|
||||
if (Math.abs(this.drag_start_x - this.drag_end_x) > 10) {
|
||||
@@ -277,7 +285,7 @@ Vue.component('result-view', {
|
||||
this.in_drag_mode = false;
|
||||
this.drag_start_x = 0;
|
||||
this.drag_end_x = 0;
|
||||
this.zoomInSliderStyle="display: none;";
|
||||
this.hideZoomInSlider();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
Reference in New Issue
Block a user