Matter-js: MouseConstraint does not work with pixelRatio above 1

Created on 1 Nov 2018  路  9Comments  路  Source: liabru/matter-js

What

When using pixelRatio: 'auto' the mouse constraint stops working on retina screens. The shapes "real" position is offset quite a lot, so you have to try to grab them where they are not drawn.

Why

Think that some calculation does not take the pixelRatio into account. Dug around a bit in the source but couldn't the cause.

Reproduction

https://codesandbox.io/s/nkm7pzmvn0

investigate need-more-info

Most helpful comment

This has been solved in commit d577477 but is not yet in a release, it will be included in the next one.

All 9 comments

Can't seem to reproduce any issues with the mouse on your example even by setting pixelRatio: 2. Did you fix your code already? Can you give more information?

Did you test with the codesandbox link? I can still reproduce the bug (can't move any of the objects) 馃 Are you testing with a screen/device that has a higher pixel ratio than 1?

I've tested on a MacBook Pro (2880 x 1800) and an iPhone 8 and both experience the same problem.

@liabru Friendly ping 馃彄

Can you clarify why you closed this? I'm still seeing issues with this.

Me too unfortunately..

This has been solved in commit d577477 but is not yet in a release, it will be included in the next one.

Is anyone still getting this issue? I'm using v0.14.2

Me too unfortunately..
Anyway thanks for the amazing work.

Setting mouse.pixelRatio = 1 fixed the issue for me:

const mouse = Mouse.create(render.canvas);
mouse.pixelRatio = 1;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zhaopengyang picture Zhaopengyang  路  3Comments

BlueInt32 picture BlueInt32  路  4Comments

drachehavoc picture drachehavoc  路  4Comments

253153 picture 253153  路  3Comments

djipco picture djipco  路  4Comments