Skip to content

Commit cd7e2a7

Browse files
Fixes #13 Not working on mobile devices / userInteraction is never set to true on touch devices (iOS / Android)
Signed-off-by: Alexandre Bonneau <[email protected]>
1 parent 9a85b3d commit cd7e2a7

File tree

5 files changed

+36
-91
lines changed

5 files changed

+36
-91
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog for vue-autoNumeric
22

3+
### 1.2.1
4+
+ Fixes #13 Not working on mobile devices / userInteraction is never set to true on touch devices (iOS / Android)
5+
+ Replace the user interaction tracking system with a simple one where the component AutoNumeric `rawValue` is compared to the watched new `value`.
6+
37
### 1.2.0
48
+ Simplify how the `rawValue` decimal places are set
59
+ In `v1.1.*`, whenever the options were changed, the number of decimal places for the `rawValue` was calculated based of the previous options, and not only the new given options.

dist/vue-autonumeric.js

+5-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-autonumeric v1.2.0 (https://github.com/autoNumeric/vue-autoNumeric)
2+
* vue-autonumeric v1.2.1 (https://github.com/autoNumeric/vue-autoNumeric)
33
* © 2018 Alexandre Bonneau <[email protected]>
44
* Released under the MIT License.
55
*/
@@ -336,14 +336,6 @@ exports.default = {
336336
attrs: attributes,
337337
ref: 'autoNumericElement',
338338
on: {
339-
keydown: this.setUserInteraction,
340-
paste: this.setUserInteraction,
341-
wheel: this.setUserInteraction,
342-
drop: this.setUserInteraction,
343-
344-
keyup: this.resetUserInteraction,
345-
blur: this.resetUserInteraction,
346-
347339
'autoNumeric:rawValueModified': this.updateVModel
348340
}
349341
});
@@ -384,9 +376,7 @@ exports.default = {
384376

385377
data: function data() {
386378
return {
387-
anElement: null,
388-
389-
userInteraction: false
379+
anElement: null
390380
};
391381
},
392382
mounted: function mounted() {
@@ -410,7 +400,6 @@ exports.default = {
410400
this.anElement.set(this.value);
411401

412402
this.updateVModel();
413-
this.resetUserInteraction();
414403
}
415404
},
416405

@@ -430,18 +419,12 @@ exports.default = {
430419
this.$emit('input', this.anElement.getNumber(), event);
431420
}
432421
},
433-
setUserInteraction: function setUserInteraction() {
434-
this.userInteraction = true;
435-
},
436-
resetUserInteraction: function resetUserInteraction() {
437-
this.userInteraction = false;
438-
},
439422
manageOptionElement: function manageOptionElement(optionElement) {
440423
var options = void 0;
441424
if (typeof optionElement === 'string' || optionElement instanceof String) {
442425
options = _autonumeric2.default.getPredefinedOptions()[optionElement];
443426
if (options === void 0 || options === null) {
444-
console.warn('The given pre-defined options [' + optionElement + '] is not recognized by autoNumeric.\nSwitching back to the default options.');
427+
console.warn('The given pre-defined options [' + optionElement + '] is not recognized by AutoNumeric.\nSwitching back to the default options.');
445428
options = defaultOptions;
446429
}
447430
} else {
@@ -469,18 +452,8 @@ exports.default = {
469452
this.anElement.update(optionsToUse);
470453
}
471454

472-
if (newValue.value !== void 0) {
473-
try {
474-
if (!this.userInteraction) {
475-
if (newValue.value !== oldValue.value) {
476-
this.anElement.set(newValue.value);
477-
}
478-
}
479-
} catch (error) {
480-
console.error(error);
481-
}
482-
483-
this.resetUserInteraction();
455+
if (newValue.value !== void 0 && this.anElement.getNumber() !== newValue.value && newValue.value !== oldValue.value) {
456+
this.anElement.set(newValue.value);
484457
}
485458
}
486459
}

0 commit comments

Comments
 (0)