Ability to return to the first page without the loop function (#36)

* Ability to return to the first page without the loop function
* Update MMM-pages.js

Co-authored-by: Edward Shen <eddie22099@gmail.com>
This commit is contained in:
Burnallover 2020-06-03 02:57:24 +02:00 committed by GitHub
parent bd8cc9f332
commit b554ee86b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 9 deletions

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);
} else 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.curPage = 0;
self.updatePages();
}, self.config.rotationFirstPage);
}, delay);
} }
}, },
}); });

View file

@ -51,13 +51,14 @@ modules: [
## Configuration options ## Configuration options
| Option | Type | Default Value | Description | | Option | Type | Default Value | Description |
| --------------- | ------------------ | ------------------------ | --------- | | ------------------ | ------------------ | ------------------------ | --------- |
| `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Notethat all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. | | `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Notethat all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. |
| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. | | `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. |
| `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. | | `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
| `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. |
| `delayTime` | `int` | `0` | 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` | `0` | 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. |
| `rotationFirstPage`| `int` | `0` | Time, in milliseconds, before automatically returning to the first page. |
For the `module` configuration option, the first element of the outer array For the `module` configuration option, the first element of the outer array
should consist of elements that should be on the first page. The second element should consist of elements that should be on the first page. The second element