Add individualRotationTimes

This commit is contained in:
Kristjan ESPERANTO 2025-02-02 05:02:59 +01:00
parent dd6415e16f
commit 693deec595
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -12,6 +12,7 @@ Module.register('MMM-pages', {
hiddenPages: {}, hiddenPages: {},
animationTime: 1000, animationTime: 1000,
rotationTime: 0, rotationTime: 0,
individualRotationTimes: [],
rotationFirstPage: 0, // Keep for compatibility rotationFirstPage: 0, // Keep for compatibility
rotationHomePage: 0, rotationHomePage: 0,
rotationDelay: 10000, rotationDelay: 10000,
@ -228,11 +229,15 @@ Module.register('MMM-pages', {
* @param {number} delay the delay, in milliseconds. * @param {number} delay the delay, in milliseconds.
*/ */
resetTimerWithDelay(delay) { resetTimerWithDelay(delay) {
if (this.config.rotationTime > 0) { if (this.config.rotationTime > 0 || this.config.individualRotationTimes.length) {
// This timer is the auto rotate function. // This timer is the auto rotate function.
clearInterval(this.timer); clearInterval(this.timer);
// This is delay timer after manually updating. // This is delay timer after manually updating.
clearInterval(this.delayTimer); clearInterval(this.delayTimer);
let currentRotationTime = this.config.rotationTime;
if (this.config.individualRotationTimes[this.curPage]) {
currentRotationTime = this.config.individualRotationTimes[this.curPage];
}
const self = this; const self = this;
this.delayTimer = setTimeout(() => { this.delayTimer = setTimeout(() => {
@ -242,7 +247,7 @@ Module.register('MMM-pages', {
// message, so we need to trigger it for ourselves. // message, so we need to trigger it for ourselves.
self.sendNotification('PAGE_INCREMENT'); self.sendNotification('PAGE_INCREMENT');
self.notificationReceived('PAGE_INCREMENT'); self.notificationReceived('PAGE_INCREMENT');
}, self.config.rotationTime); }, currentRotationTime);
}, delay); }, delay);
} else if (this.config.rotationHomePage > 0) { } else if (this.config.rotationHomePage > 0) {
// This timer is the auto rotate function. // This timer is the auto rotate function.

View file

@ -166,6 +166,7 @@ You have to add the class name to the config of the module you want to show on a
| `hiddenPages` | `{String: [String...]...}` | `{}` | An Object defining special `hiddenPages` which are not available on the normal page rotation and only accessible via a notification. Modules defined in `fixed` are ignored and need to be also added if you wish to have them on any hidden page. | | `hiddenPages` | `{String: [String...]...}` | `{}` | An Object defining special `hiddenPages` which are not available on the normal page rotation and only accessible via a notification. Modules defined in `fixed` are ignored and need to be also added if you wish to have them on any hidden page. |
| `animationTime` | `int` | `1000` | Fading animation time. Set to `0` for instant change. Value is in milliseconds (1 second = 1000 milliseconds). | | `animationTime` | `int` | `1000` | Fading animation time. Set to `0` for instant change. Value is in milliseconds (1 second = 1000 milliseconds). |
| `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. | | `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. |
| `individualRotationTimes` | `[int, int, int...]` | `[]` | An array of integers (milliseconds) that define the rotation time of each page. If the array is shorter than the number of pages, `rotationTime` will be used for the remaining pages. You only need this if you want different rotation times for each page. |
| `rotationDelay` | `int` | `10000` | Time, in milliseconds, of how long should a manual page change linger before returning to automatic page changing. In other words, how long should the timer wait for after you manually change a page. This does include the animation time, so you may wish to increase it by a few seconds or so to account for the animation time. | | `rotationDelay` | `int` | `10000` | Time, in milliseconds, of how long should a manual page change linger before returning to automatic page changing. In other words, how long should the timer wait for after you manually change a page. This does include the animation time, so you may wish to increase it by a few seconds or so to account for the animation time. |
| `rotationHomePage` | `int` | `0` | Time, in milliseconds, before automatically returning to the home page. If a home page is not set, this returns to the leftmost page instead. | | `rotationHomePage` | `int` | `0` | Time, in milliseconds, before automatically returning to the home page. If a home page is not set, this returns to the leftmost page instead. |
| `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. | | `rotationFirstPage` | *NA* | *NA* | **Deprecated**. Use `rotationHomePage` instead. |