Skip to content

Commit

Permalink
fix: only update cursor on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcursino committed Oct 6, 2021
1 parent 1027af1 commit de251f1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ export class MaskCore {
this.update(focus);
}

private update(focus = false) {
private update(focus = false, changeCursor = true) {
this.el.value = this.data.output;

this.setCursorPosition(this.data.cursorPosition, focus ? 25 : undefined);
if (changeCursor) {
this.setCursorPosition(this.data.cursorPosition, focus ? 25 : undefined);

if (!focus) this.dispatchEvent();
if (!focus) this.dispatchEvent();
}
}

private focus() {
Expand All @@ -131,21 +133,21 @@ export class MaskCore {

this.options.blur && this.options.blur(this.data);

this.update();
this.update(false, false);
}

private mouseover() {
this.options.mouseover && this.options.mouseover(this.data);

this.update();
this.update(false, false);
}

private mouseout() {
this.data.input = this.el.value;

this.options.mouseout && this.options.mouseout(this.data);

this.update();
this.update(false, false);
}

private setCursorPosition(index: number, timeout?: number) {
Expand Down

0 comments on commit de251f1

Please sign in to comment.