Skip to content

Commit

Permalink
Use evalAsync instead of timeout
Browse files Browse the repository at this point in the history
evalAsync runs after the digest and before the browser render.
This will help avoid the jitter that happens in the initialization, when you see the browser rendering the select and then rendering the "chosen"
  • Loading branch information
liorcode committed Aug 28, 2016
1 parent 8b7e137 commit f6a07c9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/angular-chosen.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}
return element.trigger('chosen:updated');
} else {
$timeout(function() {
scope.$evalAsync(function() {
chosen = element.chosen(options).data('chosen');
});
if (angular.isObject(chosen)) {
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-chosen.min.js

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

2 changes: 1 addition & 1 deletion src/chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ angular.module('localytics.directives').directive 'chosen', ['$timeout', ($timeo
return
return element.trigger('chosen:updated')
else
$timeout ->
scope.$evalAsync ->
chosen = element.chosen(options).data('chosen')
return
if angular.isObject(chosen)
Expand Down

0 comments on commit f6a07c9

Please sign in to comment.