From a4e51a0f59b7b841671120f4e1f490f49ed7a58e Mon Sep 17 00:00:00 2001 From: Zoe Xi Date: Sun, 20 Mar 2016 09:19:14 -0700 Subject: [PATCH 1/3] Fix(PanRecognizer): Make event.target actual target of panstart For issue #815. --- src/recognizers/pan.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/recognizers/pan.js b/src/recognizers/pan.js index 8cc3398e4..ef3a51d0c 100644 --- a/src/recognizers/pan.js +++ b/src/recognizers/pan.js @@ -9,6 +9,8 @@ function PanRecognizer() { this.pX = null; this.pY = null; + this.firstSrcEvent = null; + this.firstTarget = null; } inherit(PanRecognizer, AttrRecognizer, { @@ -60,6 +62,12 @@ inherit(PanRecognizer, AttrRecognizer, { }, attrTest: function(input) { + // Save the initial target element. If the threshold is greater than + // the element itself, the pointer will land on a different element. + if (input.isFirst) { + this.firstSrcEvent = input.srcEvent; + this.firstTarget = input.target; + } return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input))); }, @@ -69,6 +77,9 @@ inherit(PanRecognizer, AttrRecognizer, { this.pX = input.deltaX; this.pY = input.deltaY; + input.srcEvent = this.firstSrcEvent; + input.target = this.firstTarget; + var direction = directionStr(input.direction); if (direction) { From 3ec33067db7fe5e1b5ada083bb140aea14172de5 Mon Sep 17 00:00:00 2001 From: Zoe Xi Date: Sun, 20 Mar 2016 09:29:32 -0700 Subject: [PATCH 2/3] Fix(PanRecognizer): Added manual test page for panstart event.target For issue #815. --- tests/manual/panstart.html | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/manual/panstart.html diff --git a/tests/manual/panstart.html b/tests/manual/panstart.html new file mode 100644 index 000000000..3e2dd6131 --- /dev/null +++ b/tests/manual/panstart.html @@ -0,0 +1,61 @@ + + + + + + Hammer.js + + + + +
+
+
+
+
+
+
+ +
+ + + + + \ No newline at end of file From 2953aea82b09cfd27eee4114866d4de1a7aa0620 Mon Sep 17 00:00:00 2001 From: Zoe Xi Date: Wed, 23 Mar 2016 09:15:09 -0700 Subject: [PATCH 3/3] fix(SwipeRecognizer): make event.target the actual target where swipe started For Issue #945 --- src/recognizers/swipe.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/recognizers/swipe.js b/src/recognizers/swipe.js index fb3d66c77..1cad2d057 100644 --- a/src/recognizers/swipe.js +++ b/src/recognizers/swipe.js @@ -6,6 +6,9 @@ */ function SwipeRecognizer() { AttrRecognizer.apply(this, arguments); + + this.firstSrcEvent = null; + this.firstTarget = null; } inherit(SwipeRecognizer, AttrRecognizer, { @@ -36,6 +39,12 @@ inherit(SwipeRecognizer, AttrRecognizer, { } else if (direction & DIRECTION_VERTICAL) { velocity = input.overallVelocityY; } + // Save the initial target element. If the threshold is greater than + // the element itself, the pointer will land on a different element. + if (input.isFirst) { + this.firstSrcEvent = input.srcEvent; + this.firstTarget = input.target; + } return this._super.attrTest.call(this, input) && direction & input.offsetDirection && @@ -49,6 +58,8 @@ inherit(SwipeRecognizer, AttrRecognizer, { if (direction) { this.manager.emit(this.options.event + direction, input); } + input.srcEvent = this.firstSrcEvent; + input.target = this.firstTarget; this.manager.emit(this.options.event, input); }