cleanup animatePageChange

This commit is contained in:
Edward Shen 2020-11-23 18:29:50 -05:00
parent 62c0e5900f
commit cb4700fc19
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -197,12 +197,6 @@ Module.register('MMM-pages', {
* Optional and only used when we want to switch to a hidden page * Optional and only used when we want to switch to a hidden page
*/ */
animatePageChange: function (targetPageName) { animatePageChange: function (targetPageName) {
const self = this;
const modulesToShow = (typeof targetPageName !== 'undefined') ? this.config.hiddenPages[targetPageName] : this.config.fixed.concat(this.config.modules[this.curPage]);
// Hides all modules not on the current page. This hides any module not
// meant to be shown.
let lockStringObj = { lockString: self.identifier }; let lockStringObj = { lockString: self.identifier };
if (!this.config.useLockString) { if (!this.config.useLockString) {
// Passing in an undefined object is equivalent to not passing it in at // Passing in an undefined object is equivalent to not passing it in at
@ -210,22 +204,28 @@ Module.register('MMM-pages', {
lockStringObj = undefined; lockStringObj = undefined;
} }
// Hides all modules not on the current page. This hides any module not
// meant to be shown.
const self = this;
let modulesToShow;
if (typeof targetPageName !== 'undefined') {
modulesToShow = this.config.hiddenPages[targetPageName];
} else {
modulesToShow = this.config.fixed.concat(this.config.modules[this.curPage]);
}
const animationTime = self.config.animationTime / 2;
MM.getModules() MM.getModules()
.exceptWithClass(modulesToShow) .exceptWithClass(modulesToShow)
.enumerate(module => module.hide( .enumerate(module => module.hide(animationTime, lockStringObj));
self.config.animationTime / 2,
lockStringObj
));
// Shows all modules meant to be on the current page, after a small delay. // Shows all modules meant to be on the current page, after a small delay.
setTimeout(() => { setTimeout(() => {
MM.getModules() MM.getModules()
.withClass(modulesToShow) .withClass(modulesToShow)
.enumerate(module => module.show( .enumerate(module => module.show(animationTime, lockStringObj));
self.config.animationTime / 2, }, animationTime);
lockStringObj
));
}, this.config.animationTime / 2);
}, },
/** /**