Created
November 4, 2013 18:24
-
-
Save jakecraige/7307010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Credits to @danyhunter for initial idea and implementation | |
| # https://github.com/danyhunter | |
| ( () -> | |
| if typeof angular is 'undefined' | |
| return | |
| module = angular.module 'SteroidsKeyboardFix', [] | |
| module.directive 'input', () -> | |
| restrict: 'E' | |
| link: (scope, ele, attrs) -> | |
| isTouchDevice = ('ontouchstart' in document.documentElement) | |
| cover = angular.element('<div style="position:absolute;top:0;left:0;right:0;bottom:0;"></div>') | |
| wrapper = angular.element('<div style="position:relative"></div>') | |
| ele.wrap(wrapper) | |
| wrapper.append(cover) | |
| tapping = false | |
| if isTouchDevice | |
| cover.on 'touchstart', -> | |
| tapping = true | |
| cover.on 'touchmove', -> | |
| tapping = false | |
| cover.on 'touchend', -> | |
| ele[0].focus() if tapping | |
| else | |
| cover.on 'click', -> | |
| ele[0].focus() | |
| )() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment