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

Add support for multitouches with few target elements #2

Merged
merged 1 commit into from
Sep 16, 2014

Conversation

bumbu
Copy link
Contributor

@bumbu bumbu commented Sep 15, 2014

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.

var el = document.getElementById('element');
var cel = document.getElementById('child-element');

Simulator.gestures.pinch([el, cel], { duration: 50, scale: .5 }, function(){})

where DOM structure may look like:

<div id="element">
  <div id="child-element"></div>
</div>

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.

jtangelder added a commit that referenced this pull request Sep 16, 2014
Add support for multitouches with few target elements
@jtangelder jtangelder merged commit 76c2e30 into hammerjs:master Sep 16, 2014
@jtangelder
Copy link
Member

Great, i modified it a bit a so it still accepts a single element as an argument.

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.

None yet

2 participants