Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Mismatching coords from touch event #66

Open
cranarma opened this issue Mar 12, 2019 · 1 comment
Open

Mismatching coords from touch event #66

cranarma opened this issue Mar 12, 2019 · 1 comment

Comments

@cranarma
Copy link

cranarma commented Mar 12, 2019

The following method doesn't take into account the coordinates of the canvas element inside the window.

__proto.initEvent=function(e,nativeEvent) //line 2989 laya.core.js

If the canvas element suffers some modifications inside the window, such as translations via style properties (margin, top, left), all the touch events will work incorrectly. The following seems to fix it:

const canvas = Laya.Render._$GET_canvas()
const rect = canvas.getBoundingClientRect()
this._point.setTo(e.pageX - rect.left || e.clientX - rect.left, e.clientY - rect.top || e.pageY - rect.top)

@aopui
Copy link

aopui commented Jul 15, 2019

laya has native code so design to full window? u can use iframe show game in sub range

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

No branches or pull requests

2 participants