mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Use Math.hypot
, instead of Math.sqrt
with manual squaring (#12973)
When the PDF.js project started `Math.hypot` didn't exist yet, and until recently we still supported browsers (IE 11) without a native `Math.hypot` implementation; please see this compatibility information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot#browser_compatibility Furthermore, somewhat recently there were performance improvements of `Math.hypot` in Firefox; see https://bugzilla.mozilla.org/show_bug.cgi?id=1648820 Finally, this patch also replaces a couple of multiplications with the exponentiation operator.
This commit is contained in:
parent
3a2c259b57
commit
31098c404d
8 changed files with 23 additions and 27 deletions
|
@ -655,7 +655,7 @@ function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
|
|||
}
|
||||
|
||||
function normalizeWheelEventDirection(evt) {
|
||||
let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
||||
let delta = Math.hypot(evt.deltaX, evt.deltaY);
|
||||
const angle = Math.atan2(evt.deltaY, evt.deltaX);
|
||||
if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
|
||||
// All that is left-up oriented has to change the sign.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue