Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Fix #188 #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions dist/mask.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* angular-ui-mask
* https://github.com/angular-ui/ui-mask
* Version: 1.8.7 - 2016-07-26T15:59:07.992Z
* Version: 1.8.7 - 2016-12-16T13:23:58.004Z
* License: MIT
*/

Expand Down Expand Up @@ -59,7 +59,7 @@ angular.module('ui.mask', [])
return tempOptions;
}];
})
.directive('uiMask', ['uiMask.Config', function(maskConfig) {
.directive('uiMask', ['uiMask.Config', '$timeout', function(maskConfig, $timeout) {
function isFocused (elem) {
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
}
Expand Down Expand Up @@ -556,6 +556,8 @@ angular.module('ui.mask', [])

function eventHandler(e) {
/*jshint validthis: true */
var self = this;

e = e || {};
// Allows more efficient minification
var eventWhich = e.which,
Expand Down Expand Up @@ -681,6 +683,13 @@ angular.module('ui.mask', [])
}
oldCaretPosition = caretPos;
setCaretPosition(this, caretPos);

$timeout(function() {
var caretPos = getCaretPosition(iElement[0]);
if(caretPos < caretPosMin) {
setCaretPosition(self, caretPosMin);
}
}, 305);
}

function isValidCaretPosition(pos) {
Expand Down
4 changes: 2 additions & 2 deletions dist/mask.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion src/mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ angular.module('ui.mask', [])
return tempOptions;
}];
})
.directive('uiMask', ['uiMask.Config', function(maskConfig) {
.directive('uiMask', ['uiMask.Config', '$timeout', function(maskConfig, $timeout) {
function isFocused (elem) {
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
}
Expand Down Expand Up @@ -546,6 +546,8 @@ angular.module('ui.mask', [])

function eventHandler(e) {
/*jshint validthis: true */
var self = this;

e = e || {};
// Allows more efficient minification
var eventWhich = e.which,
Expand Down Expand Up @@ -671,6 +673,13 @@ angular.module('ui.mask', [])
}
oldCaretPosition = caretPos;
setCaretPosition(this, caretPos);

$timeout(function() {
var caretPos = getCaretPosition(iElement[0]);
if(caretPos < caretPosMin) {
setCaretPosition(self, caretPosMin);
}
}, 305);
}

function isValidCaretPosition(pos) {
Expand Down