Skip to content

Commit

Permalink
fix(MovableCoord): fire release event (naver#290)
Browse files Browse the repository at this point in the history
Ref naver#288

* fix(MovableCoord): add exception for DIRECTION_NONE

Close naver#288
  • Loading branch information
jongmoon authored Jul 29, 2016
1 parent 344c713 commit 2c4891f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/movableCoord.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,11 @@ MovableCoord에 대한 상세한 내용은 데모를 살펴보기 바란다.
// create Hammer
var hammer = new HM.Manager(el, {
recognizers: [
[
HM.Tap, {

// for long tap
time: 30000
}
],
[
HM.Pan, {
direction: subOptions.direction,
threshold: 0
}, ["tap"]
}
]
],

Expand All @@ -186,14 +179,16 @@ MovableCoord에 대한 상세한 내용은 데모를 살펴보기 바란다.
this._subOptions = options;
this._status.curHammer = hammer;
this._panstart(e);
} else if (e.isFinal) {
// substitute .on("panend tap", this._panend); Because it(tap, panend) cannot catch vertical(horizontal) movement on HORIZONTAL(VERTICAL) mode.
this._panend(e);
}
}, this))
.on("panstart panmove", this._panmove)
.on("panend tap", this._panend);
.on("panstart panmove", this._panmove);
},

_detachHammerEvents: function(hammer) {
hammer.off("hammer.input panstart panmove panend tap");
hammer.off("hammer.input panstart panmove panend");
},

_convertInputType: function(inputType) {
Expand Down Expand Up @@ -414,7 +409,7 @@ MovableCoord에 대한 상세한 내용은 데모를 살펴보기 바란다.
}

// Abort the animating post process when "tap" occurs
if (e.type === "tap") {
if (e.distance === 0 /*e.type === "tap"*/) {
this._setInterrupt(false);
this.trigger("release", {
depaPos: pos.concat(),
Expand Down
58 changes: 58 additions & 0 deletions test/unit/js/movableCoord.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,64 @@ test("movement direction test (DIRECTION_VERTICAL)", function(assert) {
});
});

test("cross movement test (vertical movement on DIRECTION_HORIZONTAL)", function(assert) {
var done = assert.async();
//Given
var el = $("#area").get(0);

/**
* release event must be expired although the direction is not concerned
*/
this.inst.on({
"release" : function(e) {
//Then
equal(e.destPos[0], 0);
equal(e.destPos[1], 0);
}
});
this.inst.bind(el, {
direction : eg.MovableCoord.DIRECTION_HORIZONTAL
});

// When
Simulator.gestures.pan(el, {
pos: [0, 0],
deltaX: 0,
deltaY: 10,
duration: 1000,
easing: "linear"
}, done);
});

test("cross movement test (horizontal movement on DIRECTION_VERTICAL)", function(assert) {
var done = assert.async();
//Given
var el = $("#area").get(0);

/**
* release event must be expired although the direction is not concerned
*/
this.inst.on({
"release" : function(e) {
//Then
equal(e.destPos[0], 0);
equal(e.destPos[1], 0);
}
});
this.inst.bind(el, {
direction : eg.MovableCoord.DIRECTION_VERTICAL
});

// When
Simulator.gestures.pan(el, {
pos: [0, 0],
deltaX: 10,
deltaY: 0,
duration: 1000,
easing: "linear"
}, done);
});

test("_convertInputType (support touch)", function() {
// Given
var globalWithToucnSupport = {
Expand Down

0 comments on commit 2c4891f

Please sign in to comment.