mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Add suspend and resume methods.
This commit is contained in:
parent
405a81c8f0
commit
c4f3009bb5
23
js/module.js
23
js/module.js
@ -110,6 +110,20 @@ var Module = Class.extend({
|
|||||||
Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
|
Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* suspend()
|
||||||
|
* This method is called when a module is hidden.
|
||||||
|
*/
|
||||||
|
suspend: function() {
|
||||||
|
Log.log(this.name + " is suspend.");
|
||||||
|
},
|
||||||
|
|
||||||
|
/* resume()
|
||||||
|
* This method is called when a module is shown.
|
||||||
|
*/
|
||||||
|
resume: function() {
|
||||||
|
Log.log(this.name + " is resumed.");
|
||||||
|
},
|
||||||
|
|
||||||
/*********************************************
|
/*********************************************
|
||||||
* The methods below don"t need subclassing. *
|
* The methods below don"t need subclassing. *
|
||||||
*********************************************/
|
*********************************************/
|
||||||
@ -291,7 +305,13 @@ var Module = Class.extend({
|
|||||||
* argument callback function - Called when the animation is done.
|
* argument callback function - Called when the animation is done.
|
||||||
*/
|
*/
|
||||||
hide: function(speed, callback) {
|
hide: function(speed, callback) {
|
||||||
MM.hideModule(this, speed, callback);
|
callback = callback || function() {};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
MM.hideModule(self, speed, function() {
|
||||||
|
self.suspend();
|
||||||
|
callback();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/* showModule(module, speed, callback)
|
/* showModule(module, speed, callback)
|
||||||
@ -301,6 +321,7 @@ var Module = Class.extend({
|
|||||||
* argument callback function - Called when the animation is done.
|
* argument callback function - Called when the animation is done.
|
||||||
*/
|
*/
|
||||||
show: function(speed, callback) {
|
show: function(speed, callback) {
|
||||||
|
this.resume();
|
||||||
MM.showModule(this, speed, callback);
|
MM.showModule(this, speed, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -208,6 +208,13 @@ socketNotificationReceived: function(notification, payload) {
|
|||||||
},
|
},
|
||||||
````
|
````
|
||||||
|
|
||||||
|
####`suspend()`
|
||||||
|
When a module is hidden (using the `module.hide()` method), the `suspend()` method will be called. By subclassing this method you can perform tasks like halting the update timers.
|
||||||
|
|
||||||
|
####`resume()`
|
||||||
|
When a module will be shown after it was previously hidden (using the `module.show()` method), the `resume()` method will be called. By subclassing this method you can perform tasks restarting the update timers.
|
||||||
|
|
||||||
|
|
||||||
### Module instance methods
|
### Module instance methods
|
||||||
|
|
||||||
Each module instance has some handy methods which can be helpfull building your module.
|
Each module instance has some handy methods which can be helpfull building your module.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user