Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngTouch): register touches properly when jQuery is used #11471

Closed
wants to merge 1 commit into from

Conversation

mgol
Copy link
Member

@mgol mgol commented Mar 31, 2015

If jQuery was used with Angular the touch logic was looking for touches
under the original event object. However, jQuery wraps all events, keeping
the original one under the originalEvent property and copies/normalizes some
of event properties. Not all properties are copied, e.g. touches which caused
them to not be recognized properly.

Thanks to @mcmar & @pomerantsev for original patch ideas.

Fixes #4001
Closes #8584
Closes #10797

@mgol
Copy link
Member Author

mgol commented Mar 31, 2015

The problem with tests for this PR is that without those changes they still pass in currently tested desktop browsers. If you run them in e.g. mobile Safari, they'd fail (with my PR they pass). I didn't find a good way to make them fail on desktop browsers as well, can we make the test run on at least one mobile browser? At lest unit tests?

@mgol
Copy link
Member Author

mgol commented Mar 31, 2015

cc @petebacondarwin @lgalfaso

x = x || 0;
y = y || 0;

var touch = document.createTouch(window, element, new Date().getTime(), x, y, x, y);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change to Date.now(), as I've seen in other places of Angular's codebase.

@pomerantsev
Copy link
Contributor

This is great.

If jQuery was used with Angular the touch logic was looking for touches
under the original event object. However, jQuery wraps all events, keeping
the original one under the originalEvent property and copies/normalizes some
of event properties. Not all properties are copied, e.g. touches which caused
them to not be recognized properly.

Thanks to @mcmar & @pomerantsev for original patch ideas.

Fixes angular#4001
Closes angular#8584
Closes angular#10797
mgol added a commit to mgol/angular.js that referenced this pull request Apr 1, 2015
@mgol
Copy link
Member Author

mgol commented Apr 1, 2015

I'll need to merge #11479 before this one to be able to run the tests on mobile Safari.

mgol added a commit that referenced this pull request Apr 2, 2015
mgol added a commit that referenced this pull request Apr 2, 2015
@petebacondarwin
Copy link
Contributor

Landed as 06a9f0a

@mgol mgol deleted the touch-jquery branch April 2, 2015 13:08
gkalpak added a commit that referenced this pull request Apr 2, 2015
…h enabled Chrome

On certain browsers (e.g. on desktop Chrome with touch-events enabled),
using the `initTouchEvent()` method (introduced in 06a9f0a) did not
correctly initialize the event, nor did the event get dispatched on
the target element.

Using the `Event` constructor and manually attaching a `TouchList`,
works around the issue (although not a proper fix).

Fixes #11471
Closes #11493
gkalpak added a commit that referenced this pull request Apr 2, 2015
…h enabled Chrome

On certain browsers (e.g. on desktop Chrome with touch-events enabled),
using the `initTouchEvent()` method (introduced in 06a9f0a) did not
correctly initialize the event, nor did the event get dispatched on
the target element.

Using the `Event` constructor and manually attaching a `TouchList`,
works around the issue (although not a proper fix).

Fixes #11471
Closes #11493
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
…h enabled Chrome

On certain browsers (e.g. on desktop Chrome with touch-events enabled),
using the `initTouchEvent()` method (introduced in 06a9f0a) did not
correctly initialize the event, nor did the event get dispatched on
the target element.

Using the `Event` constructor and manually attaching a `TouchList`,
works around the issue (although not a proper fix).

Fixes angular#11471
Closes angular#11493
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular-touch with jQuery fails to "fastclick"
5 participants