...it should be cool with scrolling now.
authorDan
Sun, 23 Nov 2008 23:53:29 -0500
changeset 60 acc7755e15b6
parent 59 a4ca1e7c0073
child 61 88b105a901be
...it should be cool with scrolling now.
scripts/volume.js
--- a/scripts/volume.js	Sun Nov 23 23:49:20 2008 -0500
+++ b/scripts/volume.js	Sun Nov 23 23:53:29 2008 -0500
@@ -95,7 +95,7 @@
   box.appendChild(field);
   
   $(box)
-    .css('top',  (( getHeight() / 2 ) - ( $(box).Height() / 2 )) + 'px')
+    .css('top',  (( getHeight() / 2 ) - ( $(box).Height() / 2 ) + getScrollOffset()) + 'px')
     .css('left', (( $(document.body).Width() / 2 ) - ( $(box).Width() / 2 )) + 'px');
   
   $(box).fadeIn(250);
@@ -163,3 +163,27 @@
   }
   return myWidth;
 }
+
+function getScrollOffset(el)
+{
+  var position;
+  var s = el || self;
+  el = el || document;
+  if ( el.scrollTop )
+  {
+    position = el.scrollTop;
+  }
+  else if (s.pageYOffset)
+  {
+    position = self.pageYOffset;
+  }
+  else if (document.documentElement && document.documentElement.scrollTop)
+  {
+    position = document.documentElement.scrollTop;
+  }
+  else if (document.body)
+  {
+    position = document.body.scrollTop;
+  }
+  return position;
+}