mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-21 00:23:02 +08:00
Caret bounds fix
This commit is contained in:
parent
280956dba3
commit
9633c99dad
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.5.0
|
||||
* simple-keyboard v2.5.1
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
|
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.5.0",
|
||||
"version": "2.5.1",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
|
@ -175,7 +175,8 @@ class Utilities {
|
||||
|
||||
updateCaretPos = (length, minus) => {
|
||||
if(minus){
|
||||
this.simpleKeyboardInstance.caretPosition = this.simpleKeyboardInstance.caretPosition - length
|
||||
if(this.simpleKeyboardInstance.caretPosition > 0)
|
||||
this.simpleKeyboardInstance.caretPosition = this.simpleKeyboardInstance.caretPosition - length
|
||||
} else {
|
||||
this.simpleKeyboardInstance.caretPosition = this.simpleKeyboardInstance.caretPosition + length;
|
||||
}
|
||||
@ -212,7 +213,7 @@ class Utilities {
|
||||
* Emojis are made out of two characters, so we must take a custom approach to trim them.
|
||||
* For more info: https://mathiasbynens.be/notes/javascript-unicode
|
||||
*/
|
||||
if(position){
|
||||
if(position && position >= 0){
|
||||
prevTwoChars = source.substring(position - 2, position)
|
||||
emojiMatched = prevTwoChars.match(emojiMatchedReg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user