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

Fix getPointer on touch devices #4866

Merged
merged 2 commits into from
Apr 8, 2018
Merged

Conversation

nmorel
Copy link
Contributor

@nmorel nmorel commented Mar 29, 2018

When dragging an object on touch device on top or left edge of a screen, the getPointer function returns an incorrect value (NaN).
To reproduce it, you can use the following demo : http://fabricjs.com/intersection and move an object to the left side.

When clientX and pageX are 0, the internal _getPointer method returns event[clientProp] which is undefined instead of 0.

pointer = event[touchProp][0][pageProp] - (event[touchProp][0][pageProp] - event[touchProp][0][clientProp]);
}

if (!pointer && pointer !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this better as typeof pointer === 'undefined' ? that is the real meaning of it, if yuo did manage to assign anything to pointer in the first if, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea it should work the same. I'll change it.

If the pointer is at x=0 or y=0, it returns NaN.
@asturur
Copy link
Member

asturur commented Apr 8, 2018

i just noticed that pageProp - ( pageProp - clientProp) is just equal to +clientProp

@asturur asturur merged commit fe55cf4 into fabricjs:master Apr 8, 2018
@asturur asturur mentioned this pull request May 8, 2018
thiagocunha pushed a commit to thiagocunha/fabric.js that referenced this pull request Nov 18, 2019
* Fix getPointer on touch devices

If the pointer is at x=0 or y=0, it returns NaN.

* Update dom_event.js
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

Successfully merging this pull request may close these issues.

2 participants