Caret bounds fix

This commit is contained in:
Francisco Hodge 2018-10-06 04:06:09 -04:00
parent 280956dba3
commit 9633c99dad
5 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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": {

View File

@ -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);