MMM-Carousel
MMM-Carousel copied to clipboard
[FEATURE REQUEST] Broadcast a notification when the slide has changed
I am using Carousel with MMM-Wallpaper and would like to change the background image when the slide transitions. I have tried with no luck to put in a this.sendNotification("LOAD_NEXT_WALLPAPER")
command in various locations into the MMM-Carousel.js file but the code just freezes when it reaches this line.
I have used a similar module MMM-Scenes in the past which broadcasts a notification each time the 'scene' changes and I have been able to successfully update the Wallpaper code to look for this notification, however I find the Carousel module to work better for me.
Try adding it right before the final brace here:
https://github.com/shbatm/MMM-Carousel/blob/22b64b2aa686b6d3c1972aef770be64082dd5f89/MMM-Carousel.js#L449
I'll test when I get a chance
That's where I had put it but no dice...
Any earlier in the moduleTransition function and the slide doesn't load properly. Put it at the end and the slide never transitions.
...
if (this.currentIndex !== 0) {
// Log.log("Trying to enable button sliderPrevBtn_" + (this.currentIndex-1));
document
.getElementById("sliderPrevBtn_" + (this.currentIndex - 1))
.classList.add("MMMCarouselAvailable");
}
}
}
this.sendNotification('LOAD_NEXT_WALLPAPER');
},
...
I figured it out.
When you put this.sendNotification() you get an error "Uncaught TypeError: this.sendNotification is not a function at Array.moduleTransition". To get around it first change the start function to look like this:
start: function () {
self=this;
},
Then you can call the sendNotification() method in the moduleTransition function by self.sendNotification(...)
I figured it out.
Nice. Please create a PR.