From dbdd8d69388ced12bab59a737bae4c25eccd2dfa Mon Sep 17 00:00:00 2001 From: radarsu Date: Fri, 16 Dec 2016 10:31:54 +0100 Subject: [PATCH 1/2] added optional setting for button --- src/phaser-kinetic-scrolling-plugin.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/phaser-kinetic-scrolling-plugin.js b/src/phaser-kinetic-scrolling-plugin.js index 7db3a30..20d09d0 100644 --- a/src/phaser-kinetic-scrolling-plugin.js +++ b/src/phaser-kinetic-scrolling-plugin.js @@ -53,7 +53,8 @@ verticalScroll: false, horizontalWheel: true, verticalWheel: false, - deltaWheel: 40 + deltaWheel: 40, + button: "", }; }; @@ -72,6 +73,7 @@ * @param {boolean} [options.horizontalWheel=true] - Enable or Disable the horizontal scrolling with mouse wheel. * @param {boolean} [options.verticalWheel=false] - Enable or Disable the vertical scrolling with mouse wheel. * @param {number} [options.deltaWheel=40] - Delta increment of the mouse wheel. + * @param {string} [options.button=""] - Phaser button code to start drag, LEFT_BUTTON, RIGHT_BUTTON, etc. */ Phaser.Plugin.KineticScrolling.prototype.configure = function (options) { @@ -104,7 +106,11 @@ /** * Event triggered when a pointer is pressed down, resets the value of variables. */ - Phaser.Plugin.KineticScrolling.prototype.beginMove = function () { + Phaser.Plugin.KineticScrolling.prototype.beginMove = function (context, pointer) { + console.log(this.settings); + if (this.settings.button && pointer.button !== Phaser.Mouse[this.settings.button]) { + return; + } this.startX = this.game.input.x; this.startY = this.game.input.y; @@ -151,7 +157,7 @@ * Event triggered when a pointer is released, calculates the automatic scrolling. */ Phaser.Plugin.KineticScrolling.prototype.endMove = function () { - + this.pressedDown = false; this.autoScrollX = false; this.autoScrollY = false; @@ -222,7 +228,7 @@ if(!this.autoScrollX && !this.autoScrollY){ this.dragging = false; } - + if (this.settings.horizontalWheel && this.velocityWheelXAbs > 0.1) { this.dragging = true; this.amplitudeX = 0; @@ -291,4 +297,4 @@ }; -} (Phaser)); \ No newline at end of file +} (Phaser)); From 3607024e515c6a53c508c0bed1f4cd4873e61b5a Mon Sep 17 00:00:00 2001 From: radarsu Date: Fri, 16 Dec 2016 21:43:58 +0100 Subject: [PATCH 2/2] console log removed --- src/phaser-kinetic-scrolling-plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phaser-kinetic-scrolling-plugin.js b/src/phaser-kinetic-scrolling-plugin.js index 20d09d0..5f6623a 100644 --- a/src/phaser-kinetic-scrolling-plugin.js +++ b/src/phaser-kinetic-scrolling-plugin.js @@ -107,7 +107,7 @@ * Event triggered when a pointer is pressed down, resets the value of variables. */ Phaser.Plugin.KineticScrolling.prototype.beginMove = function (context, pointer) { - console.log(this.settings); + if (this.settings.button && pointer.button !== Phaser.Mouse[this.settings.button]) { return; }