Skip to content

Commit

Permalink
updated demo to use newer pixi-viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfig committed Dec 18, 2018
1 parent 57fd0e7 commit 9f23839
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
25 changes: 22 additions & 3 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28434,7 +28434,7 @@ module.exports = function (_Plugin) {
if (this.paused) {
return;
}

var original = { x: this.parent.x, y: this.parent.y };
var decelerate = this.parent.plugins['decelerate'] || {};
if (this.left !== null || this.right !== null) {
var moved = void 0;
Expand Down Expand Up @@ -28477,7 +28477,7 @@ module.exports = function (_Plugin) {
}
}
if (moved) {
this.parent.emit('moved', { viewport: this.parent, type: 'clamp-x' });
this.parent.emit('moved', { viewport: this.parent, original: original, type: 'clamp-x' });
}
}
if (this.top !== null || this.bottom !== null) {
Expand Down Expand Up @@ -28521,7 +28521,7 @@ module.exports = function (_Plugin) {
}
}
if (_moved) {
this.parent.emit('moved', { viewport: this.parent, type: 'clamp-y' });
this.parent.emit('moved', { viewport: this.parent, original: original, type: 'clamp-y' });
}
}
}
Expand Down Expand Up @@ -28565,6 +28565,9 @@ module.exports = function (_Plugin) {
_this.minSpeed = typeof options.minSpeed !== 'undefined' ? options.minSpeed : 0.01;
_this.saved = [];
_this.reset();
_this.parent.on('moved', function (data) {
return _this.moved(data);
});
return _this;
}

Expand Down Expand Up @@ -28594,6 +28597,22 @@ module.exports = function (_Plugin) {
}
}
}
}, {
key: 'moved',
value: function moved(data) {
if (this.saved.length) {
var last = this.saved[this.saved.length - 1];
if (data.type === 'clamp-x') {
if (last.x === data.original.x) {
last.x = this.parent.x;
}
} else if (data.type === 'clamp-y') {
if (last.y === data.original.y) {
last.y = this.parent.y;
}
}
}
}
}, {
key: 'up',
value: function up() {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ pixi-gl-core@^1.1.4:
integrity sha1-i0tcQzsx5Bm8N53FZc4bg1qRs3I=

pixi-viewport@^3.12.0:
version "3.13.2"
resolved "https://registry.yarnpkg.com/pixi-viewport/-/pixi-viewport-3.13.2.tgz#81dd517bfe40decd619a7859f093ef1d4cca9fb8"
integrity sha512-QcIBss4ZmuP3RbnZlPaXwnjM9E4Tx1vHUggmuc9eL8EttOpNesbjGQk6db5258t7pqbVdmj7nH4K5mEbbyn4Bg==
version "3.14.0"
resolved "https://registry.yarnpkg.com/pixi-viewport/-/pixi-viewport-3.14.0.tgz#1fc9b118b43ec819d52fa1cd477722edab52d464"
integrity sha512-y6gaY0oC89EA8I+VjvOfhSmrSCGIzvOIkGBZAdX1TwqLKPE0nQnj4WCzSLjzOCe7wqsY52pO5i5MBqbqqmXoAg==
dependencies:
eventemitter3 "^3.1.0"
penner "^0.1.3"
Expand Down

0 comments on commit 9f23839

Please sign in to comment.