Improve the algorithm for proportional mouse tracking
Change the proportional algorithm so stop moving the zoom region when cursor is in a "padding region" at the edge of the screen. (The padding region is a 10th of the screen at 2x zoom, and smaller for higher zooms.) Based on earlier versions from Jon McCann and Florian Muellner. https://bugzilla.gnome.org/show_bug.cgi?id=629950
This commit is contained in:
parent
c5c66ceb98
commit
96fb6d8f16
@ -1093,10 +1093,15 @@ ZoomRegion.prototype = {
|
|||||||
let [xRoi, yRoi, widthRoi, heightRoi] = this.getROI();
|
let [xRoi, yRoi, widthRoi, heightRoi] = this.getROI();
|
||||||
let halfScreenWidth = global.screen_width / 2;
|
let halfScreenWidth = global.screen_width / 2;
|
||||||
let halfScreenHeight = global.screen_height / 2;
|
let halfScreenHeight = global.screen_height / 2;
|
||||||
let xProportion = (halfScreenWidth - xMouse) / halfScreenWidth;
|
// We want to pad with a constant distance after zooming, so divide
|
||||||
let yProportion = (halfScreenHeight - yMouse) / halfScreenHeight;
|
// by the magnification factor.
|
||||||
let xPos = xMouse + xProportion * widthRoi / 2;
|
let unscaledPadding = Math.min(this._viewPortWidth, this._viewPortHeight) / 5;
|
||||||
let yPos = yMouse + yProportion * heightRoi / 2;
|
let xPadding = unscaledPadding / this._xMagFactor;
|
||||||
|
let yPadding = unscaledPadding / this._yMagFactor;
|
||||||
|
let xProportion = (xMouse - halfScreenWidth) / halfScreenWidth; // -1 ... 1
|
||||||
|
let yProportion = (yMouse - halfScreenHeight) / halfScreenHeight; // -1 ... 1
|
||||||
|
let xPos = xMouse - xProportion * (widthRoi / 2 - xPadding);
|
||||||
|
let yPos = yMouse - yProportion * (heightRoi /2 - yPadding);
|
||||||
|
|
||||||
return [xPos, yPos];
|
return [xPos, yPos];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user