Skip to content

Commit

Permalink
Fixed the issue related to "if i scroll once in the canvas, then clic…
Browse files Browse the repository at this point in the history
…k anywhere outside, the canvas also scroll randomly", reported by Wagyl
  • Loading branch information
Juan David Nicholls Cardona authored and Juan David Nicholls Cardona committed Feb 8, 2016
1 parent eff1fc1 commit 020d220
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phaser-kinetic-scrolling-plugin",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/jdnichollsc/Phaser-Kinetic-Scrolling-Plugin",
"authors": [
"Juan David Nicholls Cardona <[email protected]>"
Expand Down
25 changes: 17 additions & 8 deletions dist/phaser-kinetic-scrolling-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Juan Nicholls <[email protected]>
* @copyright 2015 Juan Nicholls - http://jdnichollsc.github.io/Phaser-Kinetic-Scrolling-Plugin/
* @license {@link http://opensource.org/licenses/MIT}
* @version 1.0.2
* @version 1.0.3
*/

(function (Phaser) {
Expand Down Expand Up @@ -158,18 +158,27 @@

this.now = Date.now();

if (this.velocityX > 10 || this.velocityX < -10) {
if (this.game.input.activePointer.withinGame && (this.velocityX > 10 || this.velocityX < -10)) {
this.amplitudeX = 0.8 * this.velocityX;
this.targetX = Math.round(this.game.camera.x - this.amplitudeX);
this.autoScrollX = true;
}

if (this.velocityY > 10 || this.velocityY < -10) {
if (this.game.input.activePointer.withinGame && (this.velocityY > 10 || this.velocityY < -10)) {
this.amplitudeY = 0.8 * this.velocityY;
this.targetY = Math.round(this.game.camera.y - this.amplitudeY);
this.autoScrollY = true;
}

if (!this.game.input.activePointer.withinGame) {

if (this.settings.horizontalScroll) {
this.autoScrollX = true;
}
if (this.settings.verticalScroll) {
this.autoScrollY = true;
}
}
};

/**
Expand Down Expand Up @@ -204,13 +213,13 @@
}
}

if (this.settings.horizontalWheel && (this.velocityWheelX < -0.1 || this.velocityWheelX > 0.1)) {
if (this.settings.horizontalWheel && (this.velocityWheelX < -0.1 || this.velocityWheelX > 0.1 || !this.game.input.activePointer.withinGame)) {

this.game.camera.x -= this.velocityWheelX;
this.velocityWheelX *= 0.95;
}

if (this.settings.verticalWheel && (this.velocityWheelY < -0.1 || this.velocityWheelY > 0.1)) {
if (this.settings.verticalWheel && (this.velocityWheelY < -0.1 || this.velocityWheelY > 0.1 || !this.game.input.activePointer.withinGame)) {

this.game.camera.y -= this.velocityWheelY;
this.velocityWheelY *= 0.95;
Expand Down Expand Up @@ -256,10 +265,10 @@

this.game.input.onDown.remove(this.beginMove, this);

if(this.callbackID){
this.game.input.deleteMoveCallback(this.callbackID);
if (this.callbackID) {
this.game.input.deleteMoveCallback(this.callbackID);
}
else{
else {
this.game.input.deleteMoveCallback(this.moveCamera, this);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/phaser-kinetic-scrolling-plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "phaser-kinetic-scrolling-plugin",
"version": "1.0.2",
"release": "V 1.0.2",
"version": "1.0.3",
"release": "V 1.0.3",
"description": "Kinetic Scrolling Plugin for Phaser Framework",
"author": "Juan David Nicholls Cardona <[email protected]>",
"logo": "https://raw.github.com/jdnichollsc/Phaser-Kinetic-Scrolling-Plugin/gh-pages/img/plugin.png",
Expand Down
25 changes: 17 additions & 8 deletions src/phaser-kinetic-scrolling-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Juan Nicholls <[email protected]>
* @copyright 2015 Juan Nicholls - http://jdnichollsc.github.io/Phaser-Kinetic-Scrolling-Plugin/
* @license {@link http://opensource.org/licenses/MIT}
* @version 1.0.2
* @version 1.0.3
*/

(function (Phaser) {
Expand Down Expand Up @@ -158,18 +158,27 @@

this.now = Date.now();

if (this.velocityX > 10 || this.velocityX < -10) {
if (this.game.input.activePointer.withinGame && (this.velocityX > 10 || this.velocityX < -10)) {
this.amplitudeX = 0.8 * this.velocityX;
this.targetX = Math.round(this.game.camera.x - this.amplitudeX);
this.autoScrollX = true;
}

if (this.velocityY > 10 || this.velocityY < -10) {
if (this.game.input.activePointer.withinGame && (this.velocityY > 10 || this.velocityY < -10)) {
this.amplitudeY = 0.8 * this.velocityY;
this.targetY = Math.round(this.game.camera.y - this.amplitudeY);
this.autoScrollY = true;
}

if (!this.game.input.activePointer.withinGame) {

if (this.settings.horizontalScroll) {
this.autoScrollX = true;
}
if (this.settings.verticalScroll) {
this.autoScrollY = true;
}
}
};

/**
Expand Down Expand Up @@ -204,13 +213,13 @@
}
}

if (this.settings.horizontalWheel && (this.velocityWheelX < -0.1 || this.velocityWheelX > 0.1)) {
if (this.settings.horizontalWheel && (this.velocityWheelX < -0.1 || this.velocityWheelX > 0.1 || !this.game.input.activePointer.withinGame)) {

this.game.camera.x -= this.velocityWheelX;
this.velocityWheelX *= 0.95;
}

if (this.settings.verticalWheel && (this.velocityWheelY < -0.1 || this.velocityWheelY > 0.1)) {
if (this.settings.verticalWheel && (this.velocityWheelY < -0.1 || this.velocityWheelY > 0.1 || !this.game.input.activePointer.withinGame)) {

this.game.camera.y -= this.velocityWheelY;
this.velocityWheelY *= 0.95;
Expand Down Expand Up @@ -256,10 +265,10 @@

this.game.input.onDown.remove(this.beginMove, this);

if(this.callbackID){
this.game.input.deleteMoveCallback(this.callbackID);
if (this.callbackID) {
this.game.input.deleteMoveCallback(this.callbackID);
}
else{
else {
this.game.input.deleteMoveCallback(this.moveCamera, this);
}

Expand Down

0 comments on commit 020d220

Please sign in to comment.