mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-21 00:23:02 +08:00
Added methods beforeRender, beforeFirstRender
This commit is contained in:
parent
c007f7406a
commit
18a3aa9dd5
@ -703,6 +703,27 @@ class SimpleKeyboard {
|
||||
if (typeof this.options.onInit === "function") this.options.onInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the callback function before a simple-keyboard render.
|
||||
*/
|
||||
beforeFirstRender(){
|
||||
/**
|
||||
* Performing actions when touch device detected
|
||||
*/
|
||||
if(this.utilities.isTouchDevice()){
|
||||
this.onTouchDeviceDetected();
|
||||
}
|
||||
|
||||
if (typeof this.options.beforeFirstRender === "function") this.options.beforeFirstRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the callback function before a simple-keyboard render.
|
||||
*/
|
||||
beforeRender(){
|
||||
if (typeof this.options.beforeRender === "function") this.options.beforeRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
|
||||
*/
|
||||
@ -780,6 +801,18 @@ class SimpleKeyboard {
|
||||
*/
|
||||
this.clear();
|
||||
|
||||
/**
|
||||
* Calling beforeFirstRender
|
||||
*/
|
||||
if(!this.initialized){
|
||||
this.beforeFirstRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling beforeRender
|
||||
*/
|
||||
this.beforeRender();
|
||||
|
||||
let layoutClass = `hg-layout-${this.options.layoutName}`;
|
||||
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
||||
let useTouchEvents = this.options.useTouchEvents || false;
|
||||
@ -896,7 +929,7 @@ class SimpleKeyboard {
|
||||
|
||||
if (!this.initialized) {
|
||||
/**
|
||||
* Ensures that onInit is only called once per instantiation
|
||||
* Ensures that onInit and beforeFirstRender are only called once per instantiation
|
||||
*/
|
||||
this.initialized = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user