Ability to return to the first page without the loop function

This commit is contained in:
Burnallover 2020-05-29 19:10:10 +02:00 committed by GitHub
parent bd8cc9f332
commit b0b07cf2f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ Module.register('MMM-pages', {
fixed: ['MMM-page-indicator'], fixed: ['MMM-page-indicator'],
animationTime: 1000, animationTime: 1000,
rotationTime: 0, rotationTime: 0,
rotationFirstpage:0,
rotationDelay: 10000 rotationDelay: 10000
}, },
@ -52,6 +53,7 @@ Module.register('MMM-pages', {
// Disable rotation if an invalid input is given // Disable rotation if an invalid input is given
this.config.rotationTime = Math.max(this.config.rotationTime, 0); this.config.rotationTime = Math.max(this.config.rotationTime, 0);
this.config.rotationDelay = Math.max(this.config.rotationDelay, 0); this.config.rotationDelay = Math.max(this.config.rotationDelay, 0);
this.config.rotationFirstpage = Math.max(this.config.rotationFirstpage, 0);
}, },
/** /**
@ -212,6 +214,20 @@ Module.register('MMM-pages', {
self.updatePages(); self.updatePages();
}, self.config.rotationTime); }, self.config.rotationTime);
}, delay); }, delay);
} }if (this.config.rotationFirstpage > 0) {
// This timer is the auto rotate function.
clearInterval(this.timer);
// This is delay timer after manually updating.
clearInterval(this.delayTimer);
const self = this;
this.delayTimer = setTimeout(() => {
self.timer = setInterval(() => {
self.sendNotification('PAGE_CHANGED', 0);
self.changePageBy(-this.curPage);
self.updatePages();
}, self.config.rotationFirstpage);
}, delay);
}
}, },
}); });