mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-03-16 16:43:46 +08:00
Fixed issue in preventMouseDownDefault
This commit is contained in:
parent
0872203d9e
commit
a3240e4315
@ -307,6 +307,16 @@ class SimpleKeyboard {
|
|||||||
this.options.onKeyReleased(button);
|
this.options.onKeyReleased(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles container mousedown
|
||||||
|
*/
|
||||||
|
handleKeyboardContainerMouseDown(e) {
|
||||||
|
/**
|
||||||
|
* Handle event options
|
||||||
|
*/
|
||||||
|
if (this.options.preventMouseDownDefault) e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles button hold
|
* Handles button hold
|
||||||
*/
|
*/
|
||||||
@ -1271,7 +1281,7 @@ class SimpleKeyboard {
|
|||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handling onpointerup
|
* Handling parent events
|
||||||
*/
|
*/
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (
|
if (
|
||||||
@ -1280,17 +1290,24 @@ class SimpleKeyboard {
|
|||||||
!useMouseEvents
|
!useMouseEvents
|
||||||
) {
|
) {
|
||||||
document.onpointerup = () => this.handleButtonMouseUp();
|
document.onpointerup = () => this.handleButtonMouseUp();
|
||||||
|
this.keyboardDOM.onpointerdown = e =>
|
||||||
|
this.handleKeyboardContainerMouseDown(e);
|
||||||
} else if (useTouchEvents) {
|
} else if (useTouchEvents) {
|
||||||
/**
|
/**
|
||||||
* Handling ontouchend, ontouchcancel
|
* Handling ontouchend, ontouchcancel
|
||||||
*/
|
*/
|
||||||
document.ontouchend = () => this.handleButtonMouseUp();
|
document.ontouchend = () => this.handleButtonMouseUp();
|
||||||
document.ontouchcancel = () => this.handleButtonMouseUp();
|
document.ontouchcancel = () => this.handleButtonMouseUp();
|
||||||
|
|
||||||
|
this.keyboardDOM.ontouchstart = e =>
|
||||||
|
this.handleKeyboardContainerMouseDown(e);
|
||||||
} else if (!useTouchEvents) {
|
} else if (!useTouchEvents) {
|
||||||
/**
|
/**
|
||||||
* Handling mouseup
|
* Handling mouseup
|
||||||
*/
|
*/
|
||||||
document.onmouseup = () => this.handleButtonMouseUp();
|
document.onmouseup = () => this.handleButtonMouseUp();
|
||||||
|
this.keyboardDOM.onmousedown = e =>
|
||||||
|
this.handleKeyboardContainerMouseDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user