Skip to content

Commit

Permalink
fix #98 #99 and half of #100
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoryak committed Jul 31, 2014
1 parent 88decb6 commit 73eeacb
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
compiled-docs/
node_modules/
node_modules/
build/
24 changes: 19 additions & 5 deletions dist/jquery.floatThead-slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@
'cellspacing': $table.attr('cellspacing'),
'border': $table.attr('border')
});
$floatTable.css({
'borderCollapse': $table.css('borderCollapse'),
'border': $table.css('border')
});

$floatTable.addClass(opts.floatTableClass).css('margin', 0); //must have no margins or you wont be able to click on things under floating table

Expand Down Expand Up @@ -428,6 +432,14 @@
};
}

function floatContainerBorderWidth(side){
var border = $scrollContainer.css("border-"+side+"-width");
var w = 0;
if (border && ~border.indexOf('px')) {
w = parseInt(border, 10);
}
return w;
}
/**
* first performs initial calculations that we expect to not change when the table, window, or scrolling container are scrolled.
* returns a function that calculates the floating container's top and left coords. takes into account if we are using page scrolling or inner scrolling
Expand All @@ -444,12 +456,15 @@

var floatContainerHeight = $floatContainer.height();
var tableOffset = $table.offset();
var tableLeftGap = 0; //can be caused by border on container (only in locked mode)
if(locked){
var containerOffset = $scrollContainer.offset();
tableContainerGap = tableOffset.top - containerOffset.top + scrollingContainerTop;
if(haveCaption && captionAlignTop){
tableContainerGap += captionHeight;
}
tableContainerGap -= floatContainerBorderWidth('top');
tableLeftGap = floatContainerBorderWidth('left');
} else {
floatEnd = tableOffset.top - scrollingTop - floatContainerHeight + scrollingBottom + scrollbarOffset.horizontal;
}
Expand Down Expand Up @@ -497,13 +512,12 @@
if(locked && useAbsolutePositioning){ //inner scrolling, absolute positioning
if (tableContainerGap >= scrollingContainerTop) {
var gap = tableContainerGap - scrollingContainerTop;
gap = gap > 0 ? gap : 0;
top = gap;
top = gap > 0 ? gap : 0;
} else {
top = wrappedContainer ? 0 : scrollingContainerTop;
//headers stop at the top of the viewport
}
left = 0;
left = tableLeftGap;
} else if(!locked && useAbsolutePositioning) { //window scrolling, absolute positioning
if(windowTop > floatEnd + tableHeight + captionScrollOffset){
top = tableHeight - floatContainerHeight + captionScrollOffset; //scrolled past table
Expand Down Expand Up @@ -566,7 +580,7 @@
setHeaderHeight();
}
var scrollLeft = $scrollContainer.scrollLeft();
if(oldScrollLeft != scrollLeft){
if(!useAbsolutePositioning || oldScrollLeft != scrollLeft){
$floatContainer.scrollLeft(scrollLeft);
oldScrollLeft = scrollLeft;
}
Expand Down Expand Up @@ -694,4 +708,4 @@
});
return this;
};
})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion dist/jquery.floatThead-slim.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 73eeacb

Please sign in to comment.