diff --git a/js/jquery.stickytableheaders.js b/js/jquery.stickytableheaders.js index c7ca3b4..32bd041 100644 --- a/js/jquery.stickytableheaders.js +++ b/js/jquery.stickytableheaders.js @@ -132,13 +132,16 @@ scrollTop > offset.top : newTopOffset > offset.top, notScrolledPastBottom = (base.isWindowScrolling ? scrollTop : 0) < - (offset.top + $this.height() - base.$clonedHeader.height() - (base.isWindowScrolling ? 0 : newTopOffset)); + (offset.top + $this.height() - base.$clonedHeader.height() - (base.isWindowScrolling ? 0 : newTopOffset)), + notScrolledOffPage = (base.isWindowScrolling ? scrollTop : 0) < + (offset.top + $this.height() - (base.isWindowScrolling ? 0 : newTopOffset)); - if (scrolledPastTop && notScrolledPastBottom) { + if (scrolledPastTop && notScrolledOffPage) { newLeft = offset.left - scrollLeft + base.options.leftOffset; + var topMargin = notScrolledPastBottom ? 0 : offset.top + $this.height() - scrollTop - base.$clonedHeader.height(); base.$originalHeader.css({ 'position': 'fixed', - 'margin-top': 0, + 'margin-top': topMargin, 'left': newLeft, 'z-index': 1 // #18: opacity bug });