Skip to content

Commit

Permalink
Fix mobile Safari scroll when content is shorter than window
Browse files Browse the repository at this point in the history
  • Loading branch information
akfish committed Jun 28, 2014
1 parent 93e03e2 commit 38ab61c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@

function appendContent(data) {
content.append(data);

if (!scrolling) {
// Magic number, this fix buggy scroll behavior on mobile browsers
// when the content height is shorter than window's height.
var mobile_magic = 0.7;
if (!scrolling && content.height() > $(window.document).height() * mobile_magic) {
scrolling = true;
window.setTimeout(function () {
$("html, body").animate({ scrollTop: $(window.document).height() }, 500);
Expand Down

0 comments on commit 38ab61c

Please sign in to comment.