summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-16 15:21:42 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-16 15:21:42 +0000
commitbb1d4b2d864664ebce9a6c51a8383483df9ee107 (patch)
tree5c46da3ffe8b7cb8901a0ef437e93d6bcffb902a
parentc184d7b54ca6ce0032db5add90cc860bc6f5ef8d (diff)
downloadmullvadvpn-bb1d4b2d864664ebce9a6c51a8383483df9ee107.tar.xz
mullvadvpn-bb1d4b2d864664ebce9a6c51a8383483df9ee107.zip
Fix animator bugs
-rw-r--r--app/lib/tray-animator.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/app/lib/tray-animator.js b/app/lib/tray-animator.js
index eac809d4f8..b018a67a56 100644
--- a/app/lib/tray-animator.js
+++ b/app/lib/tray-animator.js
@@ -39,18 +39,18 @@ export class TrayAnimation {
* Create animation using file sequence
*
* @static
- * @param {string} filePattern - file name pattern where {} is replaced with index
+ * @param {string} filePattern - file name pattern where {s} is replaced with index
* @param {number[]} range - sequence range [start, end]
*
* @memberOf TrayAnimation
* @return {TrayAnimation}
*/
- static animationFromFileSequence(filePattern, range) {
+ static fromFileSequence(filePattern, range) {
assert(range.length === 2 && range[0] < range[1]);
let images = [];
for(let i = range[0]; i <= range[1]; i++) {
- images.push(filePattern.replace('{}', i));
+ images.push(filePattern.replace('{s}', i));
}
return new TrayAnimation(images);
@@ -93,10 +93,12 @@ export class TrayAnimation {
// change animation direction if marked for alternation
if(this._alternate) {
this._reverse = !this._reverse;
- }
- // clamp range
- nextFrame = Math.min(Math.max(0, nextFrame), this._numFrames);
+ // clamp range
+ nextFrame = Math.min(Math.max(0, nextFrame), this._numFrames - 1);
+ } else {
+ nextFrame = this._reverse ? this._numFrames - 1 : 0;
+ }
if(this._repeat) {
// repeat animation: skip corner frame by advancing once again
@@ -107,6 +109,8 @@ export class TrayAnimation {
}
}
+ console.log('nextFrame: %d', nextFrame);
+
this._currentFrame = nextFrame;
}
@@ -147,8 +151,11 @@ export class TrayAnimator {
* @memberOf TrayAnimator
*/
constructor(tray, animation) {
- this._tray = null;
- this._animation = anim;
+ assert(tray);
+ assert(animation);
+
+ this._tray = tray;
+ this._animation = animation;
this._started = false;
this._timer = null;
}