Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "pxcan", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "ESM-ready pixel library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,7 +7,12 @@ function coords(evt, canvas, zero = false) { | ||
const { offsetX, offsetY } = (canvas.width/canvas.height > canvas.clientWidth/canvas.clientHeight) ? | ||
// canvas aspect ratio wider than screen aspect ratio -> leftovers on top and bottom | ||
{ offsetX: 0, offsetY: (canvas.clientHeight - canvas.height*upscaling)/2 } : | ||
// canvas aspect ratio taller than screen aspect ratio -> leftovers on sides | ||
{ offsetY: 0, offsetX: (canvas.clientWidth - canvas.width*upscaling)/2 }; | ||
// derive the screen's position in the canvas element from the object-position css prop | ||
let offsetX = 0; | ||
let offsetY = 0; | ||
const [, xPercent, yPercent] = getComputedStyle(canvas).objectPosition.match(/^(\d+)% (\d+)%$/) || []; | ||
const aspect = canvas.width/canvas.height > canvas.clientWidth/canvas.clientHeight; | ||
if (aspect < 1) { | ||
offsetX = (canvas.clientWidth - canvas.width*upscaling) * (+xPercent/100); | ||
} else if (aspect > 1) { | ||
offsetY = (canvas.clientHeight - canvas.height*upscaling) * (+yPercent/100); | ||
} | ||
@@ -14,0 +19,0 @@ const coords = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27867
510