diff --git a/.gitignore b/.gitignore index 5877584..ae4f474 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea compiled-docs/ -node_modules/ \ No newline at end of file +node_modules/ +build/ \ No newline at end of file diff --git a/dist/jquery.floatThead-slim.js b/dist/jquery.floatThead-slim.js index 9f5c4e8..469b49f 100644 --- a/dist/jquery.floatThead-slim.js +++ b/dist/jquery.floatThead-slim.js @@ -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 @@ -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 @@ -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; } @@ -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 @@ -566,7 +580,7 @@ setHeaderHeight(); } var scrollLeft = $scrollContainer.scrollLeft(); - if(oldScrollLeft != scrollLeft){ + if(!useAbsolutePositioning || oldScrollLeft != scrollLeft){ $floatContainer.scrollLeft(scrollLeft); oldScrollLeft = scrollLeft; } @@ -694,4 +708,4 @@ }); return this; }; -})(jQuery); +})(jQuery); \ No newline at end of file diff --git a/dist/jquery.floatThead-slim.min.js b/dist/jquery.floatThead-slim.min.js index 4ed0f24..0300acb 100644 --- a/dist/jquery.floatThead-slim.min.js +++ b/dist/jquery.floatThead-slim.min.js @@ -1,3 +1,3 @@ // @preserve jQuery.floatThead 1.2.8 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2014 Misha Koryak // @license MIT -!function(a){function b(a,b,c){if(8==g){var d=j.width(),e=f.debounce(function(){var a=j.width();d!=a&&(d=a,c())},a);j.on(b,e)}else j.on(b,f.debounce(c,a))}function c(a){window.console&&window.console&&window.console.log&&window.console.log(a)}function d(){var b=a('
');a("body").append(b);var c=b.innerWidth(),d=a("div",b).innerWidth();return b.remove(),c-d}function e(a){if(a.dataTableSettings)for(var b=0;b*")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,debug:!1};var f=window._,g=function(){for(var a=3,b=document.createElement("b"),c=b.all||[];a=1+a,b.innerHTML="",c[0];);return a>4?a:document.documentMode}(),h=null,i=function(){if(g)return!1;var b=a("
");a("body").append(b);var c=b.find("col").width();return b.remove(),0==c},j=a(window),k=0;a.fn.floatThead=function(l){if(l=l||{},!f&&(f=window._||a.floatThead._,!f))throw new Error("jquery.floatThead-slim.js requires underscore. You should use the non-lite version since you do not have underscore.");if(8>g)return this;if(null==h&&(h=i(),h&&(document.createElement("fthtr"),document.createElement("fthtd"),document.createElement("fthfoot"))),f.isString(l)){var m=l,n=this;return this.filter("table").each(function(){var b=a(this).data("floatThead-attached");if(b&&f.isFunction(b[m])){var c=b[m]();"undefined"!=typeof c&&(n=c)}}),n}var o=a.extend({},a.floatThead.defaults||{},l);return a.each(l,function(b){b in a.floatThead.defaults||!o.debug||c("jQuery.floatThead: used ["+b+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+f.keys(a.floatThead.defaults).join(", "))}),this.filter(":not(."+o.floatTableClass+")").each(function(){function c(a){return a+".fth-"+x+".floatTHead"}function i(){var b=0;z.find("tr:visible").each(function(){b+=a(this).outerHeight(!0)}),Y.outerHeight(b),Z.outerHeight(b)}function l(){var a=y.outerWidth(),b=H.width()||a;if(W.width(b-E.vertical),N){var c=100*a/(b-E.vertical);R.css("width",c+"%")}else R.outerWidth(a)}function m(){B=(f.isFunction(o.scrollingTop)?o.scrollingTop(y):o.scrollingTop)||0,C=(f.isFunction(o.scrollingBottom)?o.scrollingBottom(y):o.scrollingBottom)||0}function n(){var b,c;if(U?b=T.find("col").length:(c=z.find("tr:first>"+o.cellTag),b=0,c.each(function(){b+=parseInt(a(this).attr("colspan")||1,10)})),b!=G){G=b;for(var d=[],e=[],f=[],g=0;b>g;g++)d.push(''),e.push(""),f.push("");e=e.join(""),d=d.join(""),h&&(f=f.join(""),V.html(f),ab=V.find("fthtd")),Y.html(d),Z=Y.find("th"),U||T.html(e),$=T.find("col"),S.html(e),_=S.find("col")}return b}function p(){if(!D){if(D=!0,I){var a=y.width(),b=P.width();a>b&&y.css("minWidth",a)}y.css(cb),R.css(cb),R.append(z),A.before(X),i()}}function q(){D&&(D=!1,I&&y.width(eb),X.detach(),y.prepend(z),y.css(db),R.css(db))}function r(a){I!=a&&(I=a,W.css({position:I?"absolute":"fixed"}))}function s(a,b,c,d){return h?c:d?o.getSizingRow(a,b,c):b}function t(){var a,b=n();return function(){var c=s(y,$,ab,g);if(c.length==b&&b>0){if(!U)for(a=0;b>a;a++)$.eq(a).css("width","");for(q(),a=0;b>a;a++){var d=c.get(a),e=d.offsetWidth;_.eq(a).width(e),$.eq(a).width(e)}p()}else R.append(z),y.css(db),R.css(db),i()}}function u(){var a,b=H.scrollTop(),c=0,d=K?J.outerHeight(!0):0,e=L?d:-d,f=W.height(),g=y.offset();if(N){var i=H.offset();c=g.top-i.top+b,K&&L&&(c+=d)}else a=g.top-B-f+C+E.horizontal;var k=j.scrollTop(),l=j.scrollLeft(),m=H.scrollLeft();return b=H.scrollTop(),function(i){if("windowScroll"==i?(k=j.scrollTop(),l=j.scrollLeft()):"containerScroll"==i?(b=H.scrollTop(),m=H.scrollLeft()):"init"!=i&&(k=j.scrollTop(),l=j.scrollLeft(),b=H.scrollTop(),m=H.scrollLeft()),!h||!(0>k||0>l)){if(Q)r("windowScrollDone"==i?!0:!1);else if("windowScrollDone"==i)return null;g=y.offset(),K&&L&&(g.top+=d);var n,o,s=y.outerHeight();if(N&&I){if(c>=b){var t=c-b;t=t>0?t:0,n=t}else n=O?0:b;o=0}else!N&&I?(k>a+s+e?n=s-f+e:g.top>k+B?(n=0,q()):(n=B+k-g.top+c+(L?d:0),p()),o=0):N&&!I?(c>b||b-c>s?(n=g.top-k,q()):(n=g.top+b-k-c,p()),o=g.left+m-l):N||I||(k>a+s+e?n=s+B-k+a+e:g.top>k+B?(n=g.top-k,p()):n=B,o=g.left-l);return{top:n,left:o}}}}function v(){var a=null,b=null,c=null;return function(d,e,f){null==d||a==d.top&&b==d.left||(W.css({top:d.top,left:d.left}),a=d.top,b=d.left),e&&l(),f&&i();var g=H.scrollLeft();c!=g&&(W.scrollLeft(g),c=g)}}function w(){if(H.length){var a=H.width(),b=H.height(),c=y.height(),d=y.width(),e=d>a?F:0,f=c>b?F:0;E.horizontal=d>a-f?F:0,E.vertical=c>b-e?F:0}}var x=k,y=a(this);if(y.data("floatThead-attached"))return!0;if(!y.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');var z=y.find("thead:first"),A=y.find("tbody:first");if(0==z.length)throw new Error("jQuery.floatThead must be run on a table that contains a element");var B,C,D=!1,E={vertical:0,horizontal:0},F=d(),G=0,H=o.scrollContainer(y)||a([]),I=o.useAbsolutePositioning;null==I&&(I=o.scrollContainer(y).length);var J=y.find("caption"),K=1==J.length;if(K)var L="top"===(J.css("caption-side")||J.attr("align")||"top");var M=a(''),N=H.length>0,O=!1,P=a([]),Q=9>=g&&!N&&I,R=a(""),S=a(""),T=y.find("colgroup:first"),U=!0;0==T.length&&(T=a(""),U=!1);var V=a(''),W=a('
'),X=a("
"),Y=a(''),Z=a([]),$=a([]),_=a([]),ab=a([]);if(X.append(Y),y.prepend(T),h&&(M.append(V),y.append(M)),R.append(S),W.append(R),o.copyTableClass&&R.attr("class",y.attr("class")),R.attr({cellpadding:y.attr("cellpadding"),cellspacing:y.attr("cellspacing"),border:y.attr("border")}),R.addClass(o.floatTableClass).css("margin",0),I){var bb=function(a,b){var c=a.css("position"),d="relative"==c||"absolute"==c;if(!d||b){var e={paddingLeft:a.css("paddingLeft"),paddingRight:a.css("paddingRight")};W.css(e),a=a.wrap("
").parent(),O=!0}return a};N?(P=bb(H,!0),P.append(W)):(P=bb(y),y.after(W))}else y.after(W);W.css({position:I?"absolute":"fixed",marginTop:0,top:I?0:"auto",zIndex:o.zIndex}),W.addClass(o.floatContainerClass),m();var cb={"table-layout":"fixed"},db={"table-layout":y.css("tableLayout")||"auto"},eb=y[0].style.width||"";w();var fb,gb=function(){(fb=t())()};gb();var hb=u(),ib=v();ib(hb("init"),!0);var jb=f.debounce(function(){ib(hb("windowScrollDone"),!1)},300),kb=function(){ib(hb("windowScroll"),!1),jb()},lb=function(){ib(hb("containerScroll"),!1)},mb=function(){m(),w(),gb(),hb=u(),(ib=v())(hb("resize"),!0,!0)},nb=f.debounce(function(){w(),m(),gb(),hb=u(),ib(hb("reflow"),!0)},1);N?I?H.on(c("scroll"),lb):(H.on(c("scroll"),lb),j.on(c("scroll"),kb)):j.on(c("scroll"),kb),j.on(c("load"),nb),b(o.debounceResizeMs,c("resize"),mb),y.on("reflow",nb),e(y)&&y.on("filter",nb).on("sort",nb).on("page",nb),y.data("floatThead-attached",{destroy:function(){var a=".fth-"+x;q(),y.css(db),T.remove(),h&&M.remove(),X.parent().length&&X.replaceWith(z),y.off("reflow"),H.off(a),O&&H.unwrap(),W.remove(),y.data("floatThead-attached",!1),j.off(a)},reflow:function(){nb()},setHeaderHeight:function(){i()},getFloatContainer:function(){return W},getRowGroups:function(){return D?W.find("thead").add(y.find("tbody,tfoot")):y.find("thead,tbody,tfoot")}}),k++}),this}}(jQuery); \ No newline at end of file +!function(a){function b(a,b,c){if(8==g){var d=j.width(),e=f.debounce(function(){var a=j.width();d!=a&&(d=a,c())},a);j.on(b,e)}else j.on(b,f.debounce(c,a))}function c(a){window.console&&window.console&&window.console.log&&window.console.log(a)}function d(){var b=a('
');a("body").append(b);var c=b.innerWidth(),d=a("div",b).innerWidth();return b.remove(),c-d}function e(a){if(a.dataTableSettings)for(var b=0;b*")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,debug:!1};var f=window._,g=function(){for(var a=3,b=document.createElement("b"),c=b.all||[];a=1+a,b.innerHTML="",c[0];);return a>4?a:document.documentMode}(),h=null,i=function(){if(g)return!1;var b=a("
");a("body").append(b);var c=b.find("col").width();return b.remove(),0==c},j=a(window),k=0;a.fn.floatThead=function(l){if(l=l||{},!f&&(f=window._||a.floatThead._,!f))throw new Error("jquery.floatThead-slim.js requires underscore. You should use the non-lite version since you do not have underscore.");if(8>g)return this;if(null==h&&(h=i(),h&&(document.createElement("fthtr"),document.createElement("fthtd"),document.createElement("fthfoot"))),f.isString(l)){var m=l,n=this;return this.filter("table").each(function(){var b=a(this).data("floatThead-attached");if(b&&f.isFunction(b[m])){var c=b[m]();"undefined"!=typeof c&&(n=c)}}),n}var o=a.extend({},a.floatThead.defaults||{},l);return a.each(l,function(b){b in a.floatThead.defaults||!o.debug||c("jQuery.floatThead: used ["+b+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+f.keys(a.floatThead.defaults).join(", "))}),this.filter(":not(."+o.floatTableClass+")").each(function(){function c(a){return a+".fth-"+y+".floatTHead"}function i(){var b=0;A.find("tr:visible").each(function(){b+=a(this).outerHeight(!0)}),Z.outerHeight(b),$.outerHeight(b)}function l(){var a=z.outerWidth(),b=I.width()||a;if(X.width(b-F.vertical),O){var c=100*a/(b-F.vertical);S.css("width",c+"%")}else S.outerWidth(a)}function m(){C=(f.isFunction(o.scrollingTop)?o.scrollingTop(z):o.scrollingTop)||0,D=(f.isFunction(o.scrollingBottom)?o.scrollingBottom(z):o.scrollingBottom)||0}function n(){var b,c;if(V?b=U.find("col").length:(c=A.find("tr:first>"+o.cellTag),b=0,c.each(function(){b+=parseInt(a(this).attr("colspan")||1,10)})),b!=H){H=b;for(var d=[],e=[],f=[],g=0;b>g;g++)d.push(''),e.push(""),f.push("");e=e.join(""),d=d.join(""),h&&(f=f.join(""),W.html(f),bb=W.find("fthtd")),Z.html(d),$=Z.find("th"),V||U.html(e),_=U.find("col"),T.html(e),ab=T.find("col")}return b}function p(){if(!E){if(E=!0,J){var a=z.width(),b=Q.width();a>b&&z.css("minWidth",a)}z.css(db),S.css(db),S.append(A),B.before(Y),i()}}function q(){E&&(E=!1,J&&z.width(fb),Y.detach(),z.prepend(A),z.css(eb),S.css(eb))}function r(a){J!=a&&(J=a,X.css({position:J?"absolute":"fixed"}))}function s(a,b,c,d){return h?c:d?o.getSizingRow(a,b,c):b}function t(){var a,b=n();return function(){var c=s(z,_,bb,g);if(c.length==b&&b>0){if(!V)for(a=0;b>a;a++)_.eq(a).css("width","");for(q(),a=0;b>a;a++){var d=c.get(a),e=d.offsetWidth;ab.eq(a).width(e),_.eq(a).width(e)}p()}else S.append(A),z.css(eb),S.css(eb),i()}}function u(a){var b=I.css("border-"+a+"-width"),c=0;return b&&~b.indexOf("px")&&(c=parseInt(b,10)),c}function v(){var a,b=I.scrollTop(),c=0,d=L?K.outerHeight(!0):0,e=M?d:-d,f=X.height(),g=z.offset(),i=0;if(O){var k=I.offset();c=g.top-k.top+b,L&&M&&(c+=d),c-=u("top"),i=u("left")}else a=g.top-C-f+D+F.horizontal;var l=j.scrollTop(),m=j.scrollLeft(),n=I.scrollLeft();return b=I.scrollTop(),function(k){if("windowScroll"==k?(l=j.scrollTop(),m=j.scrollLeft()):"containerScroll"==k?(b=I.scrollTop(),n=I.scrollLeft()):"init"!=k&&(l=j.scrollTop(),m=j.scrollLeft(),b=I.scrollTop(),n=I.scrollLeft()),!h||!(0>l||0>m)){if(R)r("windowScrollDone"==k?!0:!1);else if("windowScrollDone"==k)return null;g=z.offset(),L&&M&&(g.top+=d);var o,s,t=z.outerHeight();if(O&&J){if(c>=b){var u=c-b;o=u>0?u:0}else o=P?0:b;s=i}else!O&&J?(l>a+t+e?o=t-f+e:g.top>l+C?(o=0,q()):(o=C+l-g.top+c+(M?d:0),p()),s=0):O&&!J?(c>b||b-c>t?(o=g.top-l,q()):(o=g.top+b-l-c,p()),s=g.left+n-m):O||J||(l>a+t+e?o=t+C-l+a+e:g.top>l+C?(o=g.top-l,p()):o=C,s=g.left-m);return{top:o,left:s}}}}function w(){var a=null,b=null,c=null;return function(d,e,f){null==d||a==d.top&&b==d.left||(X.css({top:d.top,left:d.left}),a=d.top,b=d.left),e&&l(),f&&i();var g=I.scrollLeft();J&&c==g||(X.scrollLeft(g),c=g)}}function x(){if(I.length){var a=I.width(),b=I.height(),c=z.height(),d=z.width(),e=d>a?G:0,f=c>b?G:0;F.horizontal=d>a-f?G:0,F.vertical=c>b-e?G:0}}var y=k,z=a(this);if(z.data("floatThead-attached"))return!0;if(!z.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');var A=z.find("thead:first"),B=z.find("tbody:first");if(0==A.length)throw new Error("jQuery.floatThead must be run on a table that contains a element");var C,D,E=!1,F={vertical:0,horizontal:0},G=d(),H=0,I=o.scrollContainer(z)||a([]),J=o.useAbsolutePositioning;null==J&&(J=o.scrollContainer(z).length);var K=z.find("caption"),L=1==K.length;if(L)var M="top"===(K.css("caption-side")||K.attr("align")||"top");var N=a(''),O=I.length>0,P=!1,Q=a([]),R=9>=g&&!O&&J,S=a(""),T=a(""),U=z.find("colgroup:first"),V=!0;0==U.length&&(U=a(""),V=!1);var W=a(''),X=a('
'),Y=a("
"),Z=a(''),$=a([]),_=a([]),ab=a([]),bb=a([]);if(Y.append(Z),z.prepend(U),h&&(N.append(W),z.append(N)),S.append(T),X.append(S),o.copyTableClass&&S.attr("class",z.attr("class")),S.attr({cellpadding:z.attr("cellpadding"),cellspacing:z.attr("cellspacing"),border:z.attr("border")}),S.css({borderCollapse:z.css("borderCollapse"),border:z.css("border")}),S.addClass(o.floatTableClass).css("margin",0),J){var cb=function(a,b){var c=a.css("position"),d="relative"==c||"absolute"==c;if(!d||b){var e={paddingLeft:a.css("paddingLeft"),paddingRight:a.css("paddingRight")};X.css(e),a=a.wrap("
").parent(),P=!0}return a};O?(Q=cb(I,!0),Q.append(X)):(Q=cb(z),z.after(X))}else z.after(X);X.css({position:J?"absolute":"fixed",marginTop:0,top:J?0:"auto",zIndex:o.zIndex}),X.addClass(o.floatContainerClass),m();var db={"table-layout":"fixed"},eb={"table-layout":z.css("tableLayout")||"auto"},fb=z[0].style.width||"";x();var gb,hb=function(){(gb=t())()};hb();var ib=v(),jb=w();jb(ib("init"),!0);var kb=f.debounce(function(){jb(ib("windowScrollDone"),!1)},300),lb=function(){jb(ib("windowScroll"),!1),kb()},mb=function(){jb(ib("containerScroll"),!1)},nb=function(){m(),x(),hb(),ib=v(),(jb=w())(ib("resize"),!0,!0)},ob=f.debounce(function(){x(),m(),hb(),ib=v(),jb(ib("reflow"),!0)},1);O?J?I.on(c("scroll"),mb):(I.on(c("scroll"),mb),j.on(c("scroll"),lb)):j.on(c("scroll"),lb),j.on(c("load"),ob),b(o.debounceResizeMs,c("resize"),nb),z.on("reflow",ob),e(z)&&z.on("filter",ob).on("sort",ob).on("page",ob),z.data("floatThead-attached",{destroy:function(){var a=".fth-"+y;q(),z.css(eb),U.remove(),h&&N.remove(),Y.parent().length&&Y.replaceWith(A),z.off("reflow"),I.off(a),P&&I.unwrap(),X.remove(),z.data("floatThead-attached",!1),j.off(a)},reflow:function(){ob()},setHeaderHeight:function(){i()},getFloatContainer:function(){return X},getRowGroups:function(){return E?X.find("thead").add(z.find("tbody,tfoot")):z.find("thead,tbody,tfoot")}}),k++}),this}}(jQuery); \ No newline at end of file diff --git a/dist/jquery.floatThead.js b/dist/jquery.floatThead.js index db7ff18..4db2d53 100644 --- a/dist/jquery.floatThead.js +++ b/dist/jquery.floatThead.js @@ -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 @@ -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 @@ -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; } @@ -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 @@ -566,7 +580,7 @@ setHeaderHeight(); } var scrollLeft = $scrollContainer.scrollLeft(); - if(oldScrollLeft != scrollLeft){ + if(!useAbsolutePositioning || oldScrollLeft != scrollLeft){ $floatContainer.scrollLeft(scrollLeft); oldScrollLeft = scrollLeft; } @@ -695,7 +709,6 @@ return this; }; })(jQuery); - /* jQuery.floatThead.utils - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2014 Misha Koryak * License: MIT * diff --git a/dist/jquery.floatThead.min.js b/dist/jquery.floatThead.min.js index 9682a35..5c3cd04 100644 --- a/dist/jquery.floatThead.min.js +++ b/dist/jquery.floatThead.min.js @@ -1,3 +1,3 @@ // @preserve jQuery.floatThead 1.2.8 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2014 Misha Koryak // @license MIT -!function(a){function b(a,b,c){if(8==g){var d=j.width(),e=f.debounce(function(){var a=j.width();d!=a&&(d=a,c())},a);j.on(b,e)}else j.on(b,f.debounce(c,a))}function c(a){window.console&&window.console&&window.console.log&&window.console.log(a)}function d(){var b=a('
');a("body").append(b);var c=b.innerWidth(),d=a("div",b).innerWidth();return b.remove(),c-d}function e(a){if(a.dataTableSettings)for(var b=0;b*")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,debug:!1};var f=window._,g=function(){for(var a=3,b=document.createElement("b"),c=b.all||[];a=1+a,b.innerHTML="",c[0];);return a>4?a:document.documentMode}(),h=null,i=function(){if(g)return!1;var b=a("
");a("body").append(b);var c=b.find("col").width();return b.remove(),0==c},j=a(window),k=0;a.fn.floatThead=function(l){if(l=l||{},!f&&(f=window._||a.floatThead._,!f))throw new Error("jquery.floatThead-slim.js requires underscore. You should use the non-lite version since you do not have underscore.");if(8>g)return this;if(null==h&&(h=i(),h&&(document.createElement("fthtr"),document.createElement("fthtd"),document.createElement("fthfoot"))),f.isString(l)){var m=l,n=this;return this.filter("table").each(function(){var b=a(this).data("floatThead-attached");if(b&&f.isFunction(b[m])){var c=b[m]();"undefined"!=typeof c&&(n=c)}}),n}var o=a.extend({},a.floatThead.defaults||{},l);return a.each(l,function(b){b in a.floatThead.defaults||!o.debug||c("jQuery.floatThead: used ["+b+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+f.keys(a.floatThead.defaults).join(", "))}),this.filter(":not(."+o.floatTableClass+")").each(function(){function c(a){return a+".fth-"+x+".floatTHead"}function i(){var b=0;z.find("tr:visible").each(function(){b+=a(this).outerHeight(!0)}),Y.outerHeight(b),Z.outerHeight(b)}function l(){var a=y.outerWidth(),b=H.width()||a;if(W.width(b-E.vertical),N){var c=100*a/(b-E.vertical);R.css("width",c+"%")}else R.outerWidth(a)}function m(){B=(f.isFunction(o.scrollingTop)?o.scrollingTop(y):o.scrollingTop)||0,C=(f.isFunction(o.scrollingBottom)?o.scrollingBottom(y):o.scrollingBottom)||0}function n(){var b,c;if(U?b=T.find("col").length:(c=z.find("tr:first>"+o.cellTag),b=0,c.each(function(){b+=parseInt(a(this).attr("colspan")||1,10)})),b!=G){G=b;for(var d=[],e=[],f=[],g=0;b>g;g++)d.push(''),e.push(""),f.push("");e=e.join(""),d=d.join(""),h&&(f=f.join(""),V.html(f),ab=V.find("fthtd")),Y.html(d),Z=Y.find("th"),U||T.html(e),$=T.find("col"),S.html(e),_=S.find("col")}return b}function p(){if(!D){if(D=!0,I){var a=y.width(),b=P.width();a>b&&y.css("minWidth",a)}y.css(cb),R.css(cb),R.append(z),A.before(X),i()}}function q(){D&&(D=!1,I&&y.width(eb),X.detach(),y.prepend(z),y.css(db),R.css(db))}function r(a){I!=a&&(I=a,W.css({position:I?"absolute":"fixed"}))}function s(a,b,c,d){return h?c:d?o.getSizingRow(a,b,c):b}function t(){var a,b=n();return function(){var c=s(y,$,ab,g);if(c.length==b&&b>0){if(!U)for(a=0;b>a;a++)$.eq(a).css("width","");for(q(),a=0;b>a;a++){var d=c.get(a),e=d.offsetWidth;_.eq(a).width(e),$.eq(a).width(e)}p()}else R.append(z),y.css(db),R.css(db),i()}}function u(){var a,b=H.scrollTop(),c=0,d=K?J.outerHeight(!0):0,e=L?d:-d,f=W.height(),g=y.offset();if(N){var i=H.offset();c=g.top-i.top+b,K&&L&&(c+=d)}else a=g.top-B-f+C+E.horizontal;var k=j.scrollTop(),l=j.scrollLeft(),m=H.scrollLeft();return b=H.scrollTop(),function(i){if("windowScroll"==i?(k=j.scrollTop(),l=j.scrollLeft()):"containerScroll"==i?(b=H.scrollTop(),m=H.scrollLeft()):"init"!=i&&(k=j.scrollTop(),l=j.scrollLeft(),b=H.scrollTop(),m=H.scrollLeft()),!h||!(0>k||0>l)){if(Q)r("windowScrollDone"==i?!0:!1);else if("windowScrollDone"==i)return null;g=y.offset(),K&&L&&(g.top+=d);var n,o,s=y.outerHeight();if(N&&I){if(c>=b){var t=c-b;t=t>0?t:0,n=t}else n=O?0:b;o=0}else!N&&I?(k>a+s+e?n=s-f+e:g.top>k+B?(n=0,q()):(n=B+k-g.top+c+(L?d:0),p()),o=0):N&&!I?(c>b||b-c>s?(n=g.top-k,q()):(n=g.top+b-k-c,p()),o=g.left+m-l):N||I||(k>a+s+e?n=s+B-k+a+e:g.top>k+B?(n=g.top-k,p()):n=B,o=g.left-l);return{top:n,left:o}}}}function v(){var a=null,b=null,c=null;return function(d,e,f){null==d||a==d.top&&b==d.left||(W.css({top:d.top,left:d.left}),a=d.top,b=d.left),e&&l(),f&&i();var g=H.scrollLeft();c!=g&&(W.scrollLeft(g),c=g)}}function w(){if(H.length){var a=H.width(),b=H.height(),c=y.height(),d=y.width(),e=d>a?F:0,f=c>b?F:0;E.horizontal=d>a-f?F:0,E.vertical=c>b-e?F:0}}var x=k,y=a(this);if(y.data("floatThead-attached"))return!0;if(!y.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');var z=y.find("thead:first"),A=y.find("tbody:first");if(0==z.length)throw new Error("jQuery.floatThead must be run on a table that contains a element");var B,C,D=!1,E={vertical:0,horizontal:0},F=d(),G=0,H=o.scrollContainer(y)||a([]),I=o.useAbsolutePositioning;null==I&&(I=o.scrollContainer(y).length);var J=y.find("caption"),K=1==J.length;if(K)var L="top"===(J.css("caption-side")||J.attr("align")||"top");var M=a(''),N=H.length>0,O=!1,P=a([]),Q=9>=g&&!N&&I,R=a(""),S=a(""),T=y.find("colgroup:first"),U=!0;0==T.length&&(T=a(""),U=!1);var V=a(''),W=a('
'),X=a("
"),Y=a(''),Z=a([]),$=a([]),_=a([]),ab=a([]);if(X.append(Y),y.prepend(T),h&&(M.append(V),y.append(M)),R.append(S),W.append(R),o.copyTableClass&&R.attr("class",y.attr("class")),R.attr({cellpadding:y.attr("cellpadding"),cellspacing:y.attr("cellspacing"),border:y.attr("border")}),R.addClass(o.floatTableClass).css("margin",0),I){var bb=function(a,b){var c=a.css("position"),d="relative"==c||"absolute"==c;if(!d||b){var e={paddingLeft:a.css("paddingLeft"),paddingRight:a.css("paddingRight")};W.css(e),a=a.wrap("
").parent(),O=!0}return a};N?(P=bb(H,!0),P.append(W)):(P=bb(y),y.after(W))}else y.after(W);W.css({position:I?"absolute":"fixed",marginTop:0,top:I?0:"auto",zIndex:o.zIndex}),W.addClass(o.floatContainerClass),m();var cb={"table-layout":"fixed"},db={"table-layout":y.css("tableLayout")||"auto"},eb=y[0].style.width||"";w();var fb,gb=function(){(fb=t())()};gb();var hb=u(),ib=v();ib(hb("init"),!0);var jb=f.debounce(function(){ib(hb("windowScrollDone"),!1)},300),kb=function(){ib(hb("windowScroll"),!1),jb()},lb=function(){ib(hb("containerScroll"),!1)},mb=function(){m(),w(),gb(),hb=u(),(ib=v())(hb("resize"),!0,!0)},nb=f.debounce(function(){w(),m(),gb(),hb=u(),ib(hb("reflow"),!0)},1);N?I?H.on(c("scroll"),lb):(H.on(c("scroll"),lb),j.on(c("scroll"),kb)):j.on(c("scroll"),kb),j.on(c("load"),nb),b(o.debounceResizeMs,c("resize"),mb),y.on("reflow",nb),e(y)&&y.on("filter",nb).on("sort",nb).on("page",nb),y.data("floatThead-attached",{destroy:function(){var a=".fth-"+x;q(),y.css(db),T.remove(),h&&M.remove(),X.parent().length&&X.replaceWith(z),y.off("reflow"),H.off(a),O&&H.unwrap(),W.remove(),y.data("floatThead-attached",!1),j.off(a)},reflow:function(){nb()},setHeaderHeight:function(){i()},getFloatContainer:function(){return W},getRowGroups:function(){return D?W.find("thead").add(y.find("tbody,tfoot")):y.find("thead,tbody,tfoot")}}),k++}),this}}(jQuery),function(a){a.floatThead=a.floatThead||{},a.floatThead._=window._||function(){var b={},c=Object.prototype.hasOwnProperty,d=["Arguments","Function","String","Number","Date","RegExp"];return b.has=function(a,b){return c.call(a,b)},b.keys=function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.has(a,d)&&c.push(d);return c},a.each(d,function(){var a=this;b["is"+a]=function(b){return Object.prototype.toString.call(b)=="[object "+a+"]"}}),b.debounce=function(a,b,c){var d,e,f,g,h;return function(){f=this,e=arguments,g=new Date;var i=function(){var j=new Date-g;b>j?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e)))},j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e)),h}},b}()}(jQuery); \ No newline at end of file +!function(a){function b(a,b,c){if(8==g){var d=j.width(),e=f.debounce(function(){var a=j.width();d!=a&&(d=a,c())},a);j.on(b,e)}else j.on(b,f.debounce(c,a))}function c(a){window.console&&window.console&&window.console.log&&window.console.log(a)}function d(){var b=a('
');a("body").append(b);var c=b.innerWidth(),d=a("div",b).innerWidth();return b.remove(),c-d}function e(a){if(a.dataTableSettings)for(var b=0;b*")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,debug:!1};var f=window._,g=function(){for(var a=3,b=document.createElement("b"),c=b.all||[];a=1+a,b.innerHTML="",c[0];);return a>4?a:document.documentMode}(),h=null,i=function(){if(g)return!1;var b=a("
");a("body").append(b);var c=b.find("col").width();return b.remove(),0==c},j=a(window),k=0;a.fn.floatThead=function(l){if(l=l||{},!f&&(f=window._||a.floatThead._,!f))throw new Error("jquery.floatThead-slim.js requires underscore. You should use the non-lite version since you do not have underscore.");if(8>g)return this;if(null==h&&(h=i(),h&&(document.createElement("fthtr"),document.createElement("fthtd"),document.createElement("fthfoot"))),f.isString(l)){var m=l,n=this;return this.filter("table").each(function(){var b=a(this).data("floatThead-attached");if(b&&f.isFunction(b[m])){var c=b[m]();"undefined"!=typeof c&&(n=c)}}),n}var o=a.extend({},a.floatThead.defaults||{},l);return a.each(l,function(b){b in a.floatThead.defaults||!o.debug||c("jQuery.floatThead: used ["+b+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+f.keys(a.floatThead.defaults).join(", "))}),this.filter(":not(."+o.floatTableClass+")").each(function(){function c(a){return a+".fth-"+y+".floatTHead"}function i(){var b=0;A.find("tr:visible").each(function(){b+=a(this).outerHeight(!0)}),Z.outerHeight(b),$.outerHeight(b)}function l(){var a=z.outerWidth(),b=I.width()||a;if(X.width(b-F.vertical),O){var c=100*a/(b-F.vertical);S.css("width",c+"%")}else S.outerWidth(a)}function m(){C=(f.isFunction(o.scrollingTop)?o.scrollingTop(z):o.scrollingTop)||0,D=(f.isFunction(o.scrollingBottom)?o.scrollingBottom(z):o.scrollingBottom)||0}function n(){var b,c;if(V?b=U.find("col").length:(c=A.find("tr:first>"+o.cellTag),b=0,c.each(function(){b+=parseInt(a(this).attr("colspan")||1,10)})),b!=H){H=b;for(var d=[],e=[],f=[],g=0;b>g;g++)d.push(''),e.push(""),f.push("");e=e.join(""),d=d.join(""),h&&(f=f.join(""),W.html(f),bb=W.find("fthtd")),Z.html(d),$=Z.find("th"),V||U.html(e),_=U.find("col"),T.html(e),ab=T.find("col")}return b}function p(){if(!E){if(E=!0,J){var a=z.width(),b=Q.width();a>b&&z.css("minWidth",a)}z.css(db),S.css(db),S.append(A),B.before(Y),i()}}function q(){E&&(E=!1,J&&z.width(fb),Y.detach(),z.prepend(A),z.css(eb),S.css(eb))}function r(a){J!=a&&(J=a,X.css({position:J?"absolute":"fixed"}))}function s(a,b,c,d){return h?c:d?o.getSizingRow(a,b,c):b}function t(){var a,b=n();return function(){var c=s(z,_,bb,g);if(c.length==b&&b>0){if(!V)for(a=0;b>a;a++)_.eq(a).css("width","");for(q(),a=0;b>a;a++){var d=c.get(a),e=d.offsetWidth;ab.eq(a).width(e),_.eq(a).width(e)}p()}else S.append(A),z.css(eb),S.css(eb),i()}}function u(a){var b=I.css("border-"+a+"-width"),c=0;return b&&~b.indexOf("px")&&(c=parseInt(b,10)),c}function v(){var a,b=I.scrollTop(),c=0,d=L?K.outerHeight(!0):0,e=M?d:-d,f=X.height(),g=z.offset(),i=0;if(O){var k=I.offset();c=g.top-k.top+b,L&&M&&(c+=d),c-=u("top"),i=u("left")}else a=g.top-C-f+D+F.horizontal;var l=j.scrollTop(),m=j.scrollLeft(),n=I.scrollLeft();return b=I.scrollTop(),function(k){if("windowScroll"==k?(l=j.scrollTop(),m=j.scrollLeft()):"containerScroll"==k?(b=I.scrollTop(),n=I.scrollLeft()):"init"!=k&&(l=j.scrollTop(),m=j.scrollLeft(),b=I.scrollTop(),n=I.scrollLeft()),!h||!(0>l||0>m)){if(R)r("windowScrollDone"==k?!0:!1);else if("windowScrollDone"==k)return null;g=z.offset(),L&&M&&(g.top+=d);var o,s,t=z.outerHeight();if(O&&J){if(c>=b){var u=c-b;o=u>0?u:0}else o=P?0:b;s=i}else!O&&J?(l>a+t+e?o=t-f+e:g.top>l+C?(o=0,q()):(o=C+l-g.top+c+(M?d:0),p()),s=0):O&&!J?(c>b||b-c>t?(o=g.top-l,q()):(o=g.top+b-l-c,p()),s=g.left+n-m):O||J||(l>a+t+e?o=t+C-l+a+e:g.top>l+C?(o=g.top-l,p()):o=C,s=g.left-m);return{top:o,left:s}}}}function w(){var a=null,b=null,c=null;return function(d,e,f){null==d||a==d.top&&b==d.left||(X.css({top:d.top,left:d.left}),a=d.top,b=d.left),e&&l(),f&&i();var g=I.scrollLeft();J&&c==g||(X.scrollLeft(g),c=g)}}function x(){if(I.length){var a=I.width(),b=I.height(),c=z.height(),d=z.width(),e=d>a?G:0,f=c>b?G:0;F.horizontal=d>a-f?G:0,F.vertical=c>b-e?G:0}}var y=k,z=a(this);if(z.data("floatThead-attached"))return!0;if(!z.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');var A=z.find("thead:first"),B=z.find("tbody:first");if(0==A.length)throw new Error("jQuery.floatThead must be run on a table that contains a element");var C,D,E=!1,F={vertical:0,horizontal:0},G=d(),H=0,I=o.scrollContainer(z)||a([]),J=o.useAbsolutePositioning;null==J&&(J=o.scrollContainer(z).length);var K=z.find("caption"),L=1==K.length;if(L)var M="top"===(K.css("caption-side")||K.attr("align")||"top");var N=a(''),O=I.length>0,P=!1,Q=a([]),R=9>=g&&!O&&J,S=a(""),T=a(""),U=z.find("colgroup:first"),V=!0;0==U.length&&(U=a(""),V=!1);var W=a(''),X=a('
'),Y=a("
"),Z=a(''),$=a([]),_=a([]),ab=a([]),bb=a([]);if(Y.append(Z),z.prepend(U),h&&(N.append(W),z.append(N)),S.append(T),X.append(S),o.copyTableClass&&S.attr("class",z.attr("class")),S.attr({cellpadding:z.attr("cellpadding"),cellspacing:z.attr("cellspacing"),border:z.attr("border")}),S.css({borderCollapse:z.css("borderCollapse"),border:z.css("border")}),S.addClass(o.floatTableClass).css("margin",0),J){var cb=function(a,b){var c=a.css("position"),d="relative"==c||"absolute"==c;if(!d||b){var e={paddingLeft:a.css("paddingLeft"),paddingRight:a.css("paddingRight")};X.css(e),a=a.wrap("
").parent(),P=!0}return a};O?(Q=cb(I,!0),Q.append(X)):(Q=cb(z),z.after(X))}else z.after(X);X.css({position:J?"absolute":"fixed",marginTop:0,top:J?0:"auto",zIndex:o.zIndex}),X.addClass(o.floatContainerClass),m();var db={"table-layout":"fixed"},eb={"table-layout":z.css("tableLayout")||"auto"},fb=z[0].style.width||"";x();var gb,hb=function(){(gb=t())()};hb();var ib=v(),jb=w();jb(ib("init"),!0);var kb=f.debounce(function(){jb(ib("windowScrollDone"),!1)},300),lb=function(){jb(ib("windowScroll"),!1),kb()},mb=function(){jb(ib("containerScroll"),!1)},nb=function(){m(),x(),hb(),ib=v(),(jb=w())(ib("resize"),!0,!0)},ob=f.debounce(function(){x(),m(),hb(),ib=v(),jb(ib("reflow"),!0)},1);O?J?I.on(c("scroll"),mb):(I.on(c("scroll"),mb),j.on(c("scroll"),lb)):j.on(c("scroll"),lb),j.on(c("load"),ob),b(o.debounceResizeMs,c("resize"),nb),z.on("reflow",ob),e(z)&&z.on("filter",ob).on("sort",ob).on("page",ob),z.data("floatThead-attached",{destroy:function(){var a=".fth-"+y;q(),z.css(eb),U.remove(),h&&N.remove(),Y.parent().length&&Y.replaceWith(A),z.off("reflow"),I.off(a),P&&I.unwrap(),X.remove(),z.data("floatThead-attached",!1),j.off(a)},reflow:function(){ob()},setHeaderHeight:function(){i()},getFloatContainer:function(){return X},getRowGroups:function(){return E?X.find("thead").add(z.find("tbody,tfoot")):z.find("thead,tbody,tfoot")}}),k++}),this}}(jQuery),function(a){a.floatThead=a.floatThead||{},a.floatThead._=window._||function(){var b={},c=Object.prototype.hasOwnProperty,d=["Arguments","Function","String","Number","Date","RegExp"];return b.has=function(a,b){return c.call(a,b)},b.keys=function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.has(a,d)&&c.push(d);return c},a.each(d,function(){var a=this;b["is"+a]=function(b){return Object.prototype.toString.call(b)=="[object "+a+"]"}}),b.debounce=function(a,b,c){var d,e,f,g,h;return function(){f=this,e=arguments,g=new Date;var i=function(){var j=new Date-g;b>j?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e)))},j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e)),h}},b}()}(jQuery); \ No newline at end of file diff --git a/jquery.floatThead.js b/jquery.floatThead.js index 9f5c4e8..469b49f 100644 --- a/jquery.floatThead.js +++ b/jquery.floatThead.js @@ -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 @@ -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 @@ -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; } @@ -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 @@ -566,7 +580,7 @@ setHeaderHeight(); } var scrollLeft = $scrollContainer.scrollLeft(); - if(oldScrollLeft != scrollLeft){ + if(!useAbsolutePositioning || oldScrollLeft != scrollLeft){ $floatContainer.scrollLeft(scrollLeft); oldScrollLeft = scrollLeft; } @@ -694,4 +708,4 @@ }); return this; }; -})(jQuery); +})(jQuery); \ No newline at end of file