diff --git a/src/movableCoord.js b/src/movableCoord.js index 98ac36db..c603a6ec 100644 --- a/src/movableCoord.js +++ b/src/movableCoord.js @@ -8,6 +8,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) { "use strict"; var SUPPORT_TOUCH = "ontouchstart" in global; + var assignFn = HM.assign || HM.merge; // jscs:enable maximumLineLength /** @@ -59,7 +60,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) { */ var MC = ns.MovableCoord = ns.Class.extend(ns.Component, { construct: function(options) { - HM.assign(this.options = { + assignFn(this.options = { min: [0, 0], max: [100, 100], bounce: [10, 10, 10, 10], @@ -115,7 +116,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) { inputType: [ "touch", "mouse" ] }; - HM.assign(subOptions, options); + assignFn(subOptions, options); var inputClass = this._convertInputType(subOptions.inputType); if (!inputClass) { @@ -880,6 +881,7 @@ eg.module("movableCoord", [eg, window, "Hammer"], function(ns, global, HM) { MC.DIRECTION_ALL = MC.DIRECTION_HORIZONTAL | MC.DIRECTION_VERTICAL; return { - "MovableCoord": ns.MovableCoord + "MovableCoord": ns.MovableCoord, + "assignFn": assignFn }; }); diff --git a/test/unit/js/movableCoord.test.js b/test/unit/js/movableCoord.test.js index 99ee3b25..cc40d0f4 100644 --- a/test/unit/js/movableCoord.test.js +++ b/test/unit/js/movableCoord.test.js @@ -1345,3 +1345,27 @@ QUnit.test("_convertInputType (not support touch)", function(assert) { // Then assert.equal(inst._convertInputType(inputType), null, "type is null(not supporting touch)"); }); + +QUnit.test("assignFn (using Hammer)", function(assert) { + // Given + var mockHammer = { + merge: $.noop + }; + + // When + var method = eg.invoke("movableCoord", [eg, null, mockHammer]); + + // Then + assert.equal(!!method.assignFn, true, "using merge function"); + + // Given + mockHammer = { + assign: $.noop + }; + + // When + method = eg.invoke("movableCoord", [eg, null, mockHammer]); + + // Then + assert.equal(!!method.assignFn, true, "using assign function"); +});