themes/iphone/scrollfix.js
author Dan
Tue, 23 Dec 2008 20:20:35 -0500
changeset 64 ee64bb096f56
parent 4 cde92f6ec29f
permissions -rw-r--r--
A few miscellaneous fixes including modifying WebServer to write data in chunks (improved performance and reliability on a slow connection)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     1
function getScrollOffset()
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     2
{
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     3
  var position;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     4
  if (self.pageYOffset)
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     5
  {
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     6
    position = self.pageYOffset;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     7
  }
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     8
  else if (document.documentElement && document.documentElement.scrollTop)
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
     9
  {
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    10
    position = document.documentElement.scrollTop;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    11
  }
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    12
  else if (document.body)
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    13
  {
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    14
    position = document.body.scrollTop;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    15
  }
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    16
  return position;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    17
}
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    18
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    19
var fix_scroll = function()
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    20
{
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    21
  var div = document.getElementById('playbar');
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    22
  div.style.top = ( String(getScrollOffset()) ) + 'px';
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    23
}
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    24
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    25
window.onscroll = fix_scroll;
cde92f6ec29f Should be completely iPhone/iPod Touch-friendly now :)
Dan
parents:
diff changeset
    26