diff --git a/src/actions/drag.js b/src/actions/drag.js index 0286931fe..0284b295d 100644 --- a/src/actions/drag.js +++ b/src/actions/drag.js @@ -7,7 +7,8 @@ const defaultOptions = require('../defaultOptions'); const drag = { defaults: { - enabled : false, + enabled : false, + mouseButtons: null, origin : null, snap : null, diff --git a/src/actions/resize.js b/src/actions/resize.js index cd43c24ff..0b89a7433 100644 --- a/src/actions/resize.js +++ b/src/actions/resize.js @@ -11,7 +11,8 @@ const defaultMargin = browser.supportsTouch || browser.supportsPointerEvent? 20: const resize = { defaults: { - enabled : false, + enabled : false, + mouseButtons: null, origin : null, snap : null, diff --git a/src/autoStart/index.js b/src/autoStart/index.js index d9617d813..1a8afcff5 100644 --- a/src/autoStart/index.js +++ b/src/autoStart/index.js @@ -266,6 +266,13 @@ Interactable.prototype.defaultActionChecker = function (pointer, event, interact let action = null; for (const actionName of actions.names) { + // check mouseButton setting if the pointer is down + if (interaction.pointerIsDown + && interaction.mouse + && (event.buttons & this.options[actionName].mouseButtons) === 0) { + continue; + } + action = actions[actionName].checker(pointer, event, this, element, interaction, rect); if (action) { diff --git a/src/defaultOptions.js b/src/defaultOptions.js index 311a6c3a3..9bfb44031 100644 --- a/src/defaultOptions.js +++ b/src/defaultOptions.js @@ -9,6 +9,10 @@ module.exports = { perAction: { origin: { x: 0, y: 0 }, + // only allow left button by default + // see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#Return_value + mouseButtons: 1, + inertia: { enabled : false, resistance : 10, // the lambda in exponential decay