input-format
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -49,5 +49,30 @@ 'use strict'; | ||
// Set caret position | ||
element.setSelectionRange(caret_position, caret_position); | ||
// Set caret position. | ||
// There has been an issue with caret positioning on Android devices. | ||
// https://github.com/catamphetamine/input-format/issues/2 | ||
// I was revisiting this issue and looked for similar issues in other libraries. | ||
// For example, there's [`text-mask`](https://github.com/text-mask/text-mask) library. | ||
// They've had exactly the same issue when the caret seemingly refused to be repositioned programmatically. | ||
// The symptoms were the same: whenever the caret passed through a non-digit character of a mask (a whitespace, a bracket, a dash, etc), it looked as if it placed itself one character before its correct position. | ||
// https://github.com/text-mask/text-mask/issues/300 | ||
// They seem to have found a basic fix for it: calling `input.setSelectionRange()` in a timeout rather than instantly for Android devices. | ||
// https://github.com/text-mask/text-mask/pull/400/files | ||
// I've implemented the same workaround here. | ||
if (isAndroid()) { | ||
setTimeout(function () { | ||
return element.setSelectionRange(caret_position, caret_position); | ||
}, 0); | ||
} else { | ||
element.setSelectionRange(caret_position, caret_position); | ||
} | ||
} | ||
function isAndroid() { | ||
// `navigator` is not defined when running mocha tests. | ||
if (typeof navigator !== 'undefined') { | ||
return ANDROID_USER_AGENT_REG_EXP.test(navigator.userAgent); | ||
} | ||
} | ||
var ANDROID_USER_AGENT_REG_EXP = /Android/i; | ||
//# sourceMappingURL=dom.js.map |
@@ -10,3 +10,2 @@ 'use strict'; | ||
var count = 0; | ||
// Using `.split('')` here instead of normal `for ... of` | ||
@@ -37,5 +36,4 @@ // because the importing application doesn't neccessarily include an ES6 polyfill. | ||
} | ||
return count; | ||
} | ||
//# sourceMappingURL=helpers.js.map |
@@ -49,5 +49,30 @@ 'use strict'; | ||
// Set caret position | ||
element.setSelectionRange(caret_position, caret_position); | ||
// Set caret position. | ||
// There has been an issue with caret positioning on Android devices. | ||
// https://github.com/catamphetamine/input-format/issues/2 | ||
// I was revisiting this issue and looked for similar issues in other libraries. | ||
// For example, there's [`text-mask`](https://github.com/text-mask/text-mask) library. | ||
// They've had exactly the same issue when the caret seemingly refused to be repositioned programmatically. | ||
// The symptoms were the same: whenever the caret passed through a non-digit character of a mask (a whitespace, a bracket, a dash, etc), it looked as if it placed itself one character before its correct position. | ||
// https://github.com/text-mask/text-mask/issues/300 | ||
// They seem to have found a basic fix for it: calling `input.setSelectionRange()` in a timeout rather than instantly for Android devices. | ||
// https://github.com/text-mask/text-mask/pull/400/files | ||
// I've implemented the same workaround here. | ||
if (isAndroid()) { | ||
setTimeout(function () { | ||
return element.setSelectionRange(caret_position, caret_position); | ||
}, 0); | ||
} else { | ||
element.setSelectionRange(caret_position, caret_position); | ||
} | ||
} | ||
function isAndroid() { | ||
// `navigator` is not defined when running mocha tests. | ||
if (typeof navigator !== 'undefined') { | ||
return ANDROID_USER_AGENT_REG_EXP.test(navigator.userAgent); | ||
} | ||
} | ||
var ANDROID_USER_AGENT_REG_EXP = /Android/i; | ||
//# sourceMappingURL=dom.js.map |
@@ -10,3 +10,2 @@ 'use strict'; | ||
var count = 0; | ||
// Using `.split('')` here instead of normal `for ... of` | ||
@@ -37,5 +36,4 @@ // because the importing application doesn't neccessarily include an ES6 polyfill. | ||
} | ||
return count; | ||
} | ||
//# sourceMappingURL=helpers.js.map |
{ | ||
"name": "input-format", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Formatting user's text input on-the-fly", | ||
@@ -5,0 +5,0 @@ "main": "index.commonjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
243598
2391