themes/iphone/scrollfix.js
author Dan
Wed, 26 Mar 2008 09:57:42 -0400
changeset 11 0faea3a6c881
parent 4 cde92f6ec29f
permissions -rw-r--r--
Fixed some position slider issues; added a pulsing effect to the current track (fun!)
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