implement experimental rotation pausing

This commit is contained in:
Edward Shen 2020-04-16 19:59:19 -04:00
parent c017c9f4ab
commit c835ea2cc6
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -41,6 +41,7 @@ Module.register('MMM-pages', {
*/ */
start: function () { start: function () {
this.curPage = 0; this.curPage = 0;
this.rotationPaused = false;
// Compatibility // Compatibility
if (this.config.excludes.length) { if (this.config.excludes.length) {
@ -94,6 +95,25 @@ Module.register('MMM-pages', {
case 'QUERY_PAGE_NUMBER': case 'QUERY_PAGE_NUMBER':
this.sendNotification('PAGE_NUMBER_IS', this.curPage); this.sendNotification('PAGE_NUMBER_IS', this.curPage);
break; break;
case 'PAUSE_ROTATION':
if (!this.rotationPaused) {
Log.log('[Pages]: pausing rotation due to notification');
this.clearInterval(this.timer);
this.clearInterval(this.delayTimer);
this.rotationPaused = true;
} else {
Log.warn('[Pages]: Was asked to paused but rotation was already paused!');
}
break;
case 'RESUME_ROTATION':
if (this.rotationPaused) {
Log.log('[Pages]: resuming rotation due to notification');
this.resetTimerWithDelay(this.rotationDelay);
this.rotationPaused = false;
} else {
Log.warn('[Pages]: Was asked to resume but rotation was not paused!');
}
break;
default: // Do nothing default: // Do nothing
} }
}, },
@ -134,7 +154,9 @@ Module.register('MMM-pages', {
// Update iff there's at least one page. // Update iff there's at least one page.
if (this.config.modules.length !== 0) { if (this.config.modules.length !== 0) {
this.animatePageChange(); this.animatePageChange();
this.resetTimerWithDelay(this.config.rotationDelay); if (!this.rotationPaused) {
this.resetTimerWithDelay(this.config.rotationDelay);
}
this.sendNotification('NEW_PAGE', this.curPage); this.sendNotification('NEW_PAGE', this.curPage);
} else { Log.error("[Pages]: Pages aren't properly defined!"); } } else { Log.error("[Pages]: Pages aren't properly defined!"); }
}, },