mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-21 00:23:02 +08:00
Button hold adjustment
This commit is contained in:
parent
342918a3be
commit
2eb88579ca
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "2.7.7",
|
||||
"version": "2.7.8",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
|
@ -259,12 +259,19 @@ class SimpleKeyboard {
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
handleButtonHold(button){
|
||||
if(this.holdInteractionTimeout)
|
||||
clearTimeout(this.holdInteractionTimeout);
|
||||
|
||||
/**
|
||||
* @type {object} Timeout dictating the speed of key hold iterations
|
||||
*/
|
||||
this.holdInteractionTimeout = setTimeout(() => {
|
||||
this.handleButtonClicked(button);
|
||||
this.handleButtonHold(button);
|
||||
if(this.isMouseHold){
|
||||
this.handleButtonClicked(button);
|
||||
this.handleButtonHold(button);
|
||||
} else {
|
||||
clearTimeout(this.holdInteractionTimeout);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@ -684,7 +691,10 @@ class SimpleKeyboard {
|
||||
*/
|
||||
var buttonDOM = document.createElement('div');
|
||||
buttonDOM.className += `hg-button ${fctBtnClass}${buttonThemeClass ? " "+buttonThemeClass : ""}`;
|
||||
buttonDOM.onclick = () => this.handleButtonClicked(button);
|
||||
buttonDOM.onclick = () => {
|
||||
this.isMouseHold = false;
|
||||
this.handleButtonClicked(button);
|
||||
}
|
||||
buttonDOM.onmousedown = (e) => this.handleButtonMouseDown(button, e);
|
||||
|
||||
/**
|
||||
@ -737,17 +747,17 @@ class SimpleKeyboard {
|
||||
*/
|
||||
this.onRender();
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
|
||||
if(!this.initialized){
|
||||
/**
|
||||
* Ensures that onInit is only called once per instantiation
|
||||
*/
|
||||
this.initialized = true;
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
|
||||
/**
|
||||
* Calling onInit
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user