Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from privman/master
Browse files Browse the repository at this point in the history
Do not defer focus to next tick on iOS devices
  • Loading branch information
perplexes committed Jun 3, 2017
2 parents d8da986 + be93668 commit e892797
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/index.js

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

9 changes: 7 additions & 2 deletions ng-focus-on.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ app.directive('focusOn', function() {
app.factory('focus', [
'$rootScope', '$timeout', (function($rootScope, $timeout) {
return function(name) {
return $timeout(function() {
var _ref;
if ((_ref = navigator.platform) === 'iPod' || _ref === 'iPhone' || _ref === 'iPad') {
return $rootScope.$broadcast('focusOn', name);
});
} else {
return $timeout(function() {
return $rootScope.$broadcast('focusOn', name);
});
}
};
})
]);
Expand Down
2 changes: 1 addition & 1 deletion ng-focus-on.min.js

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

5 changes: 4 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ app.directive 'focusOn', ->

app.factory 'focus', ['$rootScope', '$timeout', (($rootScope, $timeout) ->
(name) ->
$timeout -> # wait until next tick so that all other deferred actions happen first
if navigator.platform in ['iPod', 'iPhone', 'iPad'] # iOS ignores focus events that aren't triggered in a user-initiated thread
$rootScope.$broadcast 'focusOn', name
else
$timeout -> # wait until next tick so that all other deferred actions happen first
$rootScope.$broadcast 'focusOn', name
)]

0 comments on commit e892797

Please sign in to comment.