diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-05-23 13:32:39 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-05-23 13:32:39 +0100 |
| commit | 62a40a9d3fcd24a13cf8ee998fda68b89441c2b1 (patch) | |
| tree | b66dbe42606c2b28fe3cfc630affd18734360360 | |
| parent | 9e2e6c728f6b1bcdfc171772300ff3b787db2aed (diff) | |
| parent | 7e3e9220d1a04e3ae3515725b5eab68fcc1f4315 (diff) | |
| download | mullvadvpn-62a40a9d3fcd24a13cf8ee998fda68b89441c2b1.tar.xz mullvadvpn-62a40a9d3fcd24a13cf8ee998fda68b89441c2b1.zip | |
Merge branch 'feature/refactor-animation'
| -rw-r--r-- | app/lib/tray-icon-manager.js | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/app/lib/tray-icon-manager.js b/app/lib/tray-icon-manager.js index 2dc82bacf2..1b0bab3836 100644 --- a/app/lib/tray-icon-manager.js +++ b/app/lib/tray-icon-manager.js @@ -18,7 +18,7 @@ export default class TrayIconManager { * @memberOf TrayIconManager */ constructor(tray) { - assert(tray); + assert(tray, 'Tray icon cannot be null'); const basePath = path.join(path.resolve(__dirname, '..'), 'assets/images/menubar icons'); let filePath = path.join(basePath, 'lock-{s}.png'); @@ -57,36 +57,17 @@ export default class TrayIconManager { * @memberOf TrayIconManager */ set iconType(type) { - this._updateIconType(type); - } - - /** - * Set current icon type with options - * - * @param {TrayIconType} type - new icon type - * @param {bool} skipAnimation - pass true to skip animation to last frame. Has no effect on repeating animations. - * @returns - * - * @memberOf TrayIconManager - */ - _updateIconType(type) { - // no-op if same animator requested - if(this._iconType === type) { return; } - - this._updateType(type); - } + assert(TrayIconType.isValid(type), 'Invalid icon type'); - /** - * Update icon animator with new type - * - * @param {TrayIconType} type - * - * @memberOf TrayIconManager - */ - _updateType(type) { - assert(TrayIconType.isValid(type)); + // no-op if the same type + if(this._iconType === type) { + return; + } let options = { beginFromCurrentState: true }; + if(this._iconType === null) { + options.advanceTo = 'end'; + } switch(type) { case TrayIconType.secured: @@ -98,18 +79,7 @@ export default class TrayIconManager { break; } - if(this._iconType === null) { - options.advanceTo = 'end'; - } - this._animation.play(options); - - // if(skipAnimation) { - // animator.advanceToEnd(); - // } else { - // animator.start(); - // } - this._iconType = type; } |
