Skip to content

Commit

Permalink
fix set cursor on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
uNmAnNeR committed May 27, 2017
1 parent aea626d commit 6674da2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 69 deletions.
91 changes: 35 additions & 56 deletions dist/imask.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.js.map

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions src/masks/base.js
Expand Up @@ -111,6 +111,7 @@ class BaseMask {

set cursorPos (pos) {
this.el.setSelectionRange(pos, pos);
this.saveSelection();
}

saveSelection (ev) {
Expand Down Expand Up @@ -147,21 +148,17 @@ class BaseMask {
}

updateCursor (cursorPos) {
if (this.cursorPos != cursorPos && cursorPos != null) {
this.cursorPos = cursorPos;
// also queue change cursor for mobile browsers
this._delayUpdateCursor(cursorPos);
}
this.saveSelection();
if (cursorPos == null) return;
this.cursorPos = cursorPos;

// also queue change cursor for mobile browsers
this._delayUpdateCursor(cursorPos);
}

_delayUpdateCursor (cursorPos) {
this._abortUpdateCursor();
this._changingCursorPos = cursorPos;
this._cursorChanging = setTimeout(() => {
this.cursorPos = this._changingCursorPos;
this.saveSelection();
}, 10);
this._cursorChanging = setTimeout(() => this.cursorPos = this._changingCursorPos, 10);
}

_abortUpdateCursor() {
Expand Down

0 comments on commit 6674da2

Please sign in to comment.