Skip to content

Commit 8a86540

Browse files
author
Igor Escobar
committed
adding a few comments for the future me
1 parent b68d6b5 commit 8a86540

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/jquery.mask.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@
228228
}
229229
}
230230

231+
// if the cursor is at the end keep it there
231232
if (caretPosNew > oldValL) {
232-
// if the cursor is at the end keep it there
233233
caretPosNew = newValL * 10;
234-
}
235-
else if (caretPosOld >= caretPosNew && caretPosOld !== oldValL) {
234+
} else if (caretPosOld >= caretPosNew && caretPosOld !== oldValL) {
236235
if (!p.maskDigitPosMapOld[caretPosNew]) {
237236
var caretPos = caretPosNew;
238237
caretPosNew -= maskDigitsBeforeCaretAllOld - maskDigitsBeforeCaretAll;
@@ -259,6 +258,8 @@
259258
var newVal = p.getMasked(),
260259
caretPos = p.getCaret();
261260

261+
// this is a compensation to devices/browsers that don't compensate
262+
// caret positioning the right way
262263
setTimeout(function() {
263264
p.setCaret(p.calculateCaretPosition());
264265
}, 10);

0 commit comments

Comments
 (0)