Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Created November 4, 2013 18:24
Show Gist options
  • Select an option

  • Save jakecraige/7307010 to your computer and use it in GitHub Desktop.

Select an option

Save jakecraige/7307010 to your computer and use it in GitHub Desktop.
# 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