Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixed multiple targets for drag.

  • Loading branch information...
commit 1b4b8e72452143e6a0b4d1cd4925f735f99fe84e 1 parent 553b7cd
Nicolas Gryman authored

Showing 2 changed files with 21 additions and 0 deletions. Show diff stats Hide diff stats

  1. +7 0 src/jquery.finger.js
  2. +14 0 test/jquery.finger_test.js
7 src/jquery.finger.js
@@ -60,6 +60,13 @@
60 60 }
61 61 }
62 62
  63 + // for delegated events, the target may change over time
  64 + // this ensures we notify the right target and simulates the mouseleave behavior
  65 + if (event.target !== data.start.target) {
  66 + stopHandler.call(this, $.Event(stopEvent + '.finger', event));
  67 + return;
  68 + }
  69 +
63 70 // fire drag event
64 71 $.event.trigger($.Event('drag' + $.expando, data.move), null, event.target);
65 72 }
14 test/jquery.finger_test.js
@@ -339,6 +339,20 @@
339 339 }, 100, 100);
340 340 }, 100, 100);
341 341 });
  342 +
  343 + it('should correctly stop at the edge of an element for delegated events', function(done) {
  344 + var targets = [];
  345 + $('body').on('drag', '.touchme', function(event) {
  346 + console.log(event.target);
  347 + if (-1 == targets.indexOf(event.target)) {
  348 + targets.push(event.target);
  349 + }
  350 + });
  351 + this.drag(function() {
  352 + targets.length.should.equal(1);
  353 + done();
  354 + }, 0, 200);
  355 + });
342 356 });
343 357
344 358 describe('flick event', function() {

0 comments on commit 1b4b8e7

Please sign in to comment.
Something went wrong with that request. Please try again.