Skip to content

Commit bf5d4cf

Browse files
committed
fix(MovableCoord): add support Hammer 2.0.4, 2.0.5
ref naver#431
1 parent d00ab0e commit bf5d4cf

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/movableCoord.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) {
88
"use strict";
99

1010
var SUPPORT_TOUCH = "ontouchstart" in global;
11+
var assignFn = ("assign" in HM) ? HM.assign : HM.merge;
1112

1213
// jscs:enable maximumLineLength
1314
/**
@@ -59,7 +60,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) {
5960
*/
6061
var MC = ns.MovableCoord = ns.Class.extend(ns.Component, {
6162
construct: function(options) {
62-
HM.assign(this.options = {
63+
assignFn(this.options = {
6364
min: [0, 0],
6465
max: [100, 100],
6566
bounce: [10, 10, 10, 10],
@@ -115,7 +116,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) {
115116
inputType: [ "touch", "mouse" ]
116117
};
117118

118-
HM.assign(subOptions, options);
119+
assignFn(subOptions, options);
119120

120121
var inputClass = this._convertInputType(subOptions.inputType);
121122
if (!inputClass) {
@@ -880,6 +881,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) {
880881
MC.DIRECTION_ALL = MC.DIRECTION_HORIZONTAL | MC.DIRECTION_VERTICAL;
881882

882883
return {
883-
"MovableCoord": ns.MovableCoord
884+
"MovableCoord": ns.MovableCoord,
885+
"assignFn": assignFn
884886
};
885887
});

test/unit/js/movableCoord.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -1345,3 +1345,27 @@ QUnit.test("_convertInputType (not support touch)", function(assert) {
13451345
// Then
13461346
assert.equal(inst._convertInputType(inputType), null, "type is null(not supporting touch)");
13471347
});
1348+
1349+
QUnit.test("assignFn (using Hammer)", function(assert) {
1350+
// Given
1351+
var mockHammer = {
1352+
merge: function() {}
1353+
};
1354+
1355+
// When
1356+
var method = eg.invoke("movableCoord", [eg, null, mockHammer]);
1357+
1358+
// Then
1359+
assert.equal(!!method.assignFn, true, "using merge function");
1360+
1361+
// Given
1362+
mockHammer = {
1363+
assign: function() {}
1364+
};
1365+
1366+
// When
1367+
method = eg.invoke("movableCoord", [eg, null, mockHammer]);
1368+
1369+
// Then
1370+
assert.equal(!!method.assignFn, true, "using assign function");
1371+
});

0 commit comments

Comments
 (0)