Add support for multitouches with few target elements #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
Right now it is possible to simulate only multitouch events that have as a target one single element.
This pull request adds possibility to simulate multitouch events that have multiple targets.
Related to hammerjs/hammer.js#600 (will allow creating tests that that issue).
Changes
API did not change. Hammer.js tests are passing 100%.
In order to simulate a multitouch event (ex. pinch) that has multiple targets it is enough to pass an array of elements instead of one element.
where DOM structure may look like:
If only one element is specified
Simulator.gestures.pinch([el])
then it will be applied to both events as target.If more elements are specified
Simulator.gestures.pinch([el, el1, el2, el3])
only first X will be used where X is the number of touches.Side effects
It may be observed that number of triggered events is multiplied by number of touches (right now at max 2 touches are simulated). It is done in order to simulate moving of each touch separately. Also when touchend happens it is first performed for one finger and then for the other.