Skip to content

Commit

Permalink
Force iOS keyboard not to center the focused field
Browse files Browse the repository at this point in the history
  • Loading branch information
martent committed Jan 17, 2014
1 parent f37d0f1 commit 7301b7d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/javascripts/behaviour.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ $ ->
# Scroll to search box on narrow devices
$q = $("#q")
if $q.length
if $(document).width() <= 2568
if $(document).width() <= 568
newY = $("#q").offset().top
$("body").css("min-height", $(document).height() + newY)
$q.focus ->
$q.css("font-size", "16px") # hack to prevent iOS from zooming
$(document).scrollTop(newY - 6)
$("html, body").animate
scrollTop: newY - 6
, 100

else # set focus on field if not a narrow device and if no search field is empty
$q.focus() unless $q.val().length

0 comments on commit 7301b7d

Please sign in to comment.