Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transformPointerPosition gives incorrect coordinates when the context is scaled #162

Open
onurkerimov opened this issue Dec 24, 2018 · 1 comment

Comments

@onurkerimov
Copy link

When the 2D rendering context is scaled, (here is a reason for scaling) things like .dragAndDrop() fails. Example setup:

let ratio = 0.8 // some value other than 1
let canvas = document.createElement('CANVAS')
let context = cnv.getContext('2d')
document.body.appendChild(canvas)
context.scale(ratio, ratio)

let oc = oCanvas.create({
	canvas: canvas
})

Since the ratio is different from 1, mouse position in terms of document pixels and mouse position in terms of canvas pixels becomes two separate things, x and y values that transformPointerPosition should be multiplied accordingly, to the context scaling ratio.

@onurkerimov
Copy link
Author

I just made the following pull request for the issue: #163
By the way your library is awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant