Skip to content

Commit

Permalink
Fixed iOS warnings on scrollTop
Browse files Browse the repository at this point in the history
  • Loading branch information
martent committed Jan 17, 2014
1 parent 7301b7d commit a465c41
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/javascripts/behaviour.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ $ ->
$("body").css("min-height", $(document).height() + newY)
$q.focus ->
$q.css("font-size", "16px") # hack to prevent iOS from zooming
$("html, body").animate
scrollTop: newY - 6
, 100

times = 0
i = setInterval ->
window.scrollTo(0, $q.offset().top - 6)
if times++ > 20
clearInterval(i)
, 10
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 a465c41

Please sign in to comment.