mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +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",
|
"name": "simple-keyboard",
|
||||||
"version": "2.7.7",
|
"version": "2.7.8",
|
||||||
"description": "On-screen Javascript Virtual Keyboard",
|
"description": "On-screen Javascript Virtual Keyboard",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -259,12 +259,19 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
handleButtonHold(button){
|
handleButtonHold(button){
|
||||||
|
if(this.holdInteractionTimeout)
|
||||||
|
clearTimeout(this.holdInteractionTimeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {object} Timeout dictating the speed of key hold iterations
|
* @type {object} Timeout dictating the speed of key hold iterations
|
||||||
*/
|
*/
|
||||||
this.holdInteractionTimeout = setTimeout(() => {
|
this.holdInteractionTimeout = setTimeout(() => {
|
||||||
this.handleButtonClicked(button);
|
if(this.isMouseHold){
|
||||||
this.handleButtonHold(button);
|
this.handleButtonClicked(button);
|
||||||
|
this.handleButtonHold(button);
|
||||||
|
} else {
|
||||||
|
clearTimeout(this.holdInteractionTimeout);
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,7 +691,10 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
var buttonDOM = document.createElement('div');
|
var buttonDOM = document.createElement('div');
|
||||||
buttonDOM.className += `hg-button ${fctBtnClass}${buttonThemeClass ? " "+buttonThemeClass : ""}`;
|
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);
|
buttonDOM.onmousedown = (e) => this.handleButtonMouseDown(button, e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -737,17 +747,17 @@ class SimpleKeyboard {
|
|||||||
*/
|
*/
|
||||||
this.onRender();
|
this.onRender();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handling mouseup
|
||||||
|
*/
|
||||||
|
document.onmouseup = () => this.handleButtonMouseUp();
|
||||||
|
|
||||||
if(!this.initialized){
|
if(!this.initialized){
|
||||||
/**
|
/**
|
||||||
* Ensures that onInit is only called once per instantiation
|
* Ensures that onInit is only called once per instantiation
|
||||||
*/
|
*/
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Handling mouseup
|
|
||||||
*/
|
|
||||||
document.onmouseup = () => this.handleButtonMouseUp();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling onInit
|
* Calling onInit
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user