diff --git a/misc/tableheader.js b/misc/tableheader.js
index 47201b2..9e46604 100644
--- a/misc/tableheader.js
+++ b/misc/tableheader.js
@@ -87,15 +87,16 @@ Drupal.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (eve
   var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
   if (calculateWidth || this.viewHeight !== viewHeight) {
     this.viewHeight = viewHeight;
-    this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
-    this.hPosition = this.originalTable.offset().left;
-    this.vLength = this.originalTable[0].clientHeight - 100;
+    this.vPosition = this.originalHeader.offset().top;
+    var tHeadRelativeTop = this.vPosition - this.originalTable.offset().top;
+    this.hPosition = this.originalHeader.offset().left;
+    this.vLength = this.originalTable[0].clientHeight - tHeadRelativeTop + this.stickyOffsetTop - 100;
     calculateWidth = true;
   }
 
   // Track horizontal positioning relative to the viewport and set visibility.
   var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
-  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
+  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition + this.stickyOffsetTop;
   this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
   this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
 
