Add new tests for View & Interaction w/ fixes

This commit is contained in:
jahow
2019-01-14 22:11:54 +01:00
committed by Olivier Guyot
parent a6f65df8c4
commit cd186ada7f
4 changed files with 57 additions and 22 deletions

View File

@@ -653,7 +653,7 @@ class View extends BaseObject {
/**
* @private
* @param {number|undefined} opt_rotation
* @param {number=} opt_rotation Take into account the rotation of the viewport when giving the size
* @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
*/
getSizeFromViewport_(opt_rotation) {
@@ -666,8 +666,10 @@ class View extends BaseObject {
size[1] = parseInt(metrics.height, 10);
}
if (opt_rotation) {
size[0] = Math.abs(size[0] * Math.cos(opt_rotation)) + Math.abs(size[1] * Math.sin(opt_rotation));
size[1] = Math.abs(size[0] * Math.sin(opt_rotation)) + Math.abs(size[1] * Math.cos(opt_rotation));
const w = size[0];
const h = size[1];
size[0] = Math.abs(w * Math.cos(opt_rotation)) + Math.abs(h * Math.sin(opt_rotation));
size[1] = Math.abs(w * Math.sin(opt_rotation)) + Math.abs(h * Math.cos(opt_rotation));
}
return size;
}