From b554ee86b185b146334788e605e354b0ea358f66 Mon Sep 17 00:00:00 2001 From: Burnallover <44618082+Burnallover@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:57:24 +0200 Subject: [PATCH] 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 --- MMM-pages.js | 18 +++++++++++++++++- readme.md | 17 +++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/MMM-pages.js b/MMM-pages.js index 1907cdd..df7142e 100644 --- a/MMM-pages.js +++ b/MMM-pages.js @@ -14,6 +14,7 @@ Module.register('MMM-pages', { fixed: ['MMM-page-indicator'], animationTime: 1000, rotationTime: 0, + rotationFirstPage: 0, rotationDelay: 10000 }, @@ -52,6 +53,7 @@ Module.register('MMM-pages', { // Disable rotation if an invalid input is given this.config.rotationTime = Math.max(this.config.rotationTime, 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.config.rotationTime); }, 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); + } }, }); diff --git a/readme.md b/readme.md index 34d4853..a816bd1 100644 --- a/readme.md +++ b/readme.md @@ -50,14 +50,15 @@ modules: [ ## Configuration options -| 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. | -| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. | -| `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). | -| `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. | +| 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. | +| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. | +| `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). | +| `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. | +| `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 should consist of elements that should be on the first page. The second element