Pointer Event Movement Y Not Working on Iphone

Hi all,

I tried to create custom camera movement using pointer, this is the PG : Custom Camera Movement, it work propery on Android device, but it doest work on IPhone.

I have found the cause and it turns out that the problem is in the “movementY” property (please see line #40), the property is null on the IPhone device.

Why it happens and how to fix it ?

Thanks! :slight_smile:

cc @PolygonalSun

1 Like

Hey @Muhamad_Rifky1, lemme take a look and see if I can figure out what’s going on.

1 Like

Hi @PolygonalSun, yes sure, thank you! :slight_smile:

So from what I’ve found, it appears as though PointerEvents on iOS don’t have the movementX/Y property (at least I couldn’t find it) so that approach might not work. You could try a different approach by first getting the value for clientY on a pointerdown and then using the difference between that and your pointermove’s clientY value as your offset. Here’s an example: Camera Movement Like Ikonospace | Babylon.js Playground (babylonjs.com)

While this isn’t a perfect solution, this might be a possible option

1 Like

Oh, I see. So, I can’t use movementY because IOS not provide that property on pointer event. Thanks @PolygonalSun. I will try different approach

I found the solution. so to find the value of offsetY/movementY I use the formula currentEvent.movementY = currentEvent.screenY - previousEvent.screenY

This is the PG: Custom Camera Movement [Solved] | Babylon.js Playground (babylonjs.com)

Reference : MouseEvent.movementY - Web APIs | MDN (mozilla.org)