diff --git a/CHANGELOG.md b/CHANGELOG.md index 851eab1..8b324b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +### 2.1.3 +Maintenance release. + +bug fixes: +- #409 - inf recursion printing on FireFox +- #385 - bottom offset not respected in 'absolute' mode +- #303 - scrollContainer with other content inside wrapper, header won't scroll out +- #424 - table header fractional width set incorrectly. + +### 2.1.2 +Maintenance release. + +bug fixes: +- #363 - scroll container assigned incorrect width because of a jquery 3.2.0 bug + +new features: +- bad rtl support (only works with internal scrolling, not window scrolling) + ### 2.1.1 I goofed, forgot to build dist last release. @@ -34,6 +52,7 @@ Breaking changes: - removed allowing deprecated options from 1.3.x - moved development version into /src dir and no longer use grunt here + nothing big and exciting in version 2, just semvar and breaking changes. bug fixes: diff --git a/README.md b/README.md index 6b8646f..e196522 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ npm install floatthead bower install floatThead ``` #### Download code -[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.1.2.zip) +[Latest Release (zip)](https://github.com/mkoryak/floatThead/archive/2.1.3.zip) #### Via CDN [http://cdnjs.com/libraries/floatthead/](http://cdnjs.com/libraries/floatthead/) diff --git a/dist/jquery.floatThead.js b/dist/jquery.floatThead.js index 52fe94d..004a10e 100644 --- a/dist/jquery.floatThead.js +++ b/dist/jquery.floatThead.js @@ -141,11 +141,11 @@ var _afterPrint = window.onafterprint; window.onbeforeprint = function () { _beforePrint && _beforePrint(); - $window.triggerHandler("beforeprint"); + $window.triggerHandler("fth-beforeprint"); }; window.onafterprint = function () { _afterPrint && _afterPrint(); - $window.triggerHandler("afterprint"); + $window.triggerHandler("fth-afterprint"); }; } @@ -508,7 +508,7 @@ var percent = 100 * tw / (floatContainerWidth); $floatTable.css('width', percent+'%'); } else { - $floatTable.outerWidth(tw); + $floatTable.css('width', tw+'px'); } } @@ -780,6 +780,9 @@ var gap = tableContainerGap - scrollingContainerTop + tableTopGap; top = gap > 0 ? gap : 0; triggerFloatEvent(false); + } else if(scrollingContainerTop - tableContainerGap > tableHeight - floatContainerHeight){ + // scrolled past table but there is space in the container under it.. + top = tableHeight - floatContainerHeight - scrollingContainerTop - tableContainerGap; } else { top = wrappedContainer ? tableTopGap : scrollingContainerTop; //headers stop at the top of the viewport @@ -788,7 +791,7 @@ left = tableLeftGap; } else if(!locked && useAbsolutePositioning) { //window scrolling, absolute positioning if(windowTop > floatEnd + tableHeight + captionScrollOffset){ - top = tableHeight - floatContainerHeight + captionScrollOffset; //scrolled past table + top = tableHeight - floatContainerHeight + captionScrollOffset + scrollingBottom; //scrolled past table } else if (tableOffset.top >= windowTop + scrollingTop) { top = 0; //scrolling to table unfloat(); @@ -975,8 +978,8 @@ matchMediaPrint = window.matchMedia("print"); matchMediaPrint.addListener(printEvent); } else { - $window.on('beforeprint', beforePrint); - $window.on('afterprint', afterPrint); + $window.on('fth-beforeprint', beforePrint); + $window.on('fth-afterprint', afterPrint); } ////// end printing stuff @@ -1073,6 +1076,7 @@ $floatContainer.remove(); $table.data('floatThead-attached', false); $window.off(ns); + $window.off('fth-beforeprint fth-afterprint'); // Not bound with id, so cant use ns. if (matchMediaPrint) { matchMediaPrint.removeListener(printEvent); } diff --git a/dist/jquery.floatThead.min.js b/dist/jquery.floatThead.min.js index 3c65c03..61cebde 100644 --- a/dist/jquery.floatThead.min.js +++ b/dist/jquery.floatThead.min.js @@ -1,2 +1,2 @@ /** @preserve jQuery.floatThead 2.1.2 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/ -!function(ht){ht.floatThead=ht.floatThead||{},ht.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(t){return ht([])},responsiveContainer:function(t){return ht([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,autoReflow:!1,debug:!1,support:{bootstrap:!0,datatables:!0,jqueryUI:!0,perfectScrollbar:!0},floatContainerCss:{"overflow-x":"hidden"}};var vt=function(){var n={},o=Object.prototype.hasOwnProperty;n.has=function(t,e){return o.call(t,e)},n.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var o in t)n.has(t,o)&&e.push(o);return e};var r=0;return n.uniqueId=function(t){var e=++r+"";return t?t+e:e},ht.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var e=this;n["is"+e]=function(t){return Object.prototype.toString.call(t)=="[object "+e+"]"}}),n.debounce=function(o,n,r){var a,i,l,s,d;return function(){l=this,i=arguments,s=new Date;var e=function(){var t=new Date-s;t").css("width",0).append(ht("").css("max-width","100%").append(ht("").append(ht("
").append(ht("
").css("min-width",100).text("X")))));ht("body").append(t);var e=0==t.find("table").width();return t.remove(),e}return!1},mt=!t&&!wt,yt=ht(window),Tt=t&&window.matchMedia;if(!window.matchMedia||Tt){var e=window.onbeforeprint,o=window.onafterprint;window.onbeforeprint=function(){e&&e(),yt.triggerHandler("beforeprint")},window.onafterprint=function(){o&&o(),yt.triggerHandler("afterprint")}}function Ct(t){var e=t[0].parentElement;do{if("visible"!=window.getComputedStyle(e).getPropertyValue("overflow"))break}while(e=e.parentElement);return e==document.body?ht([]):ht(e)}function xt(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function jt(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function St(){var t=document.createElement("scrolltester");t.style.cssText="width:100px;height:100px;overflow:scroll!important;position:absolute;top:-9999px;display:block",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}function zt(t,e,o){var n=o?"outerWidth":"width";if(l&&t.css("max-width")){var r=0;o&&(r+=parseInt(t.css("borderLeft"),10),r+=parseInt(t.css("borderRight"),10));for(var a=0;a http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+pt.floatTableClass+")").each(function(){var e=vt.uniqueId(),m=ht(this);if(m.data("floatThead-attached"))return!0;if(!m.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');bt=pt.autoReflow&&bt;var d=m.children("thead:first"),o=m.children("tbody:first");if(0==d.length||0==o.length)return pt.debug&&(0==d.length?xt("The thead element is missing."):xt("The tbody element is missing.")),m.data("floatThead-lazy",pt),void m.unbind("reflow").one("reflow",function(){m.floatThead(pt)});m.data("floatThead-lazy")&&m.unbind("reflow"),m.data("floatThead-lazy",!1);var y,n,r=!0,T={vertical:0,horizontal:0};vt.isFunction(St)&&(St=St());var f=0;!0===pt.scrollContainer&&(pt.scrollContainer=Ct);var C=pt.scrollContainer(m)||ht([]),x=0").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),W=!1,l=ht([]),H=wt<=9&&!x&&z,c=ht(""),u=ht(""),p=m.children("colgroup:first"),h=!0;0==p.length&&(p=ht(""),h=!1);var v=ht("").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),q=ht("
").css(pt.floatContainerCss).attr("aria-hidden","true"),R=!1,s=ht("
"),b=ht(''),w=ht([]),g=ht([]),M=ht([]),E=ht([]);s.append(b),m.prepend(p),mt&&(i.append(v),m.append(i)),c.append(u),q.append(c),pt.copyTableClass&&c.attr("class",m.attr("class")),c.attr({cellpadding:m.attr("cellpadding"),cellspacing:m.attr("cellspacing"),border:m.attr("border")});var t=m.css("display");if(c.css({borderCollapse:m.css("borderCollapse"),border:m.css("border"),display:t}),x||c.css("width","auto"),"none"===t&&(R=!0),c.addClass(pt.floatTableClass).css({margin:0,"border-bottom-width":0}),z){var k=function(t,e){var o=t.css("position"),n=t;if(!("relative"==o||"absolute"==o)||e){var r={paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight")};q.css(r),n=t.data("floatThead-containerWrap")||t.wrap(ht("
").addClass(pt.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),t.data("floatThead-containerWrap",n),W=!0}return n};x?(l=k(C,!0)).prepend(q):(l=k(m),m.before(q))}else m.before(q);q.css({position:z?"absolute":"fixed",marginTop:0,top:z?0:"auto",zIndex:pt.zIndex,willChange:"transform"}),q.addClass(pt.floatContainerClass),U();var D={"table-layout":"fixed"},F={"table-layout":m.css("tableLayout")||"auto"},O=m[0].style.width||"",N=m.css("minWidth")||"";function A(t){return t+".fth-"+e+".floatTHead"}function Q(){var t=0;if(d.children("tr:visible").each(function(){t+=ht(this).outerHeight(!0)}),"collapse"==m.css("border-collapse")){var e=parseInt(m.css("border-top-width"),10);parseInt(m.find("thead tr:first").find(">*:first").css("border-top-width"),10)'),r.push("
"),a.push(ht("").css({display:"table-cell",height:0,width:"auto"}));r=r.join(""),n=n.join(""),mt&&(v.empty(),v.append(a),E=v.find("fthtd")),b.html(n),w=b.find("th"),h||p.html(r),g=p.find("col"),u.html(r),M=u.find("col")}return t}();return function(){var t=q.scrollLeft();g=p.find("col");var e,o,n,r,a=(e=m,o=g,n=E,r=wt,mt?n:r?pt.getSizingRow(e,o,n):o);if(a.length==s&&0=v+y?(o=0,P(),X(!1)):(o=y+v-u.top+s+(L?d:0),G(),X(!0)),n=g):x&&!z?(lv+y?(o=u.top-v,G(),X(!1)):(o=y,X(!0)),n=u.left+g-b);return{top:Math.round(o),left:Math.round(n)}}}}function Z(){var i=null,l=null,s=null;return function(t,e,o){if(null!=t&&(i!=t.top||l!=t.left)){if(8===wt)q.css({top:t.top,left:t.left});else{var n="translateX("+t.left+"px) translateY("+t.top+"px)",r={"-webkit-transform":n,"-moz-transform":n,"-ms-transform":n,"-o-transform":n,transform:n,top:0};r[/rtl/i.test(document.documentElement.dir||"")?"right":"left"]=0,q.css(r)}i=t.top,l=t.left}e&&function(){var t=zt(m,E,!0),e=S?j:C,o=e.length?jt(e[0]):t,n="hidden"!=e.css("overflow-y")?o-T.vertical:o;if(q.width(n),x){var r=100*t/n;c.css("width",r+"%")}else c.outerWidth(t)}(),o&&Q();var a=(S?j:C).scrollLeft();z&&s==a||(q.scrollLeft(a),s=a)}}function _(){if(C.length)if(pt.support&&pt.support.perfectScrollbar&&C.data().perfectScrollbar)T={horizontal:0,vertical:0};else{if("scroll"==C.css("overflow-x"))T.horizontal=St;else{var t=C.width(),e=zt(m,E),o=ntable>thead").add(m.children("tbody,tfoot")):m.children("thead,tbody,tfoot")}})}),this}}(function(){var t=window.jQuery;return"undefined"!=typeof module&&module.exports&&!t&&(t=require("jquery")),t}()); \ No newline at end of file +!function(ht){ht.floatThead=ht.floatThead||{},ht.floatThead.defaults={headerCellSelector:"tr:visible:first>*:visible",zIndex:1001,position:"auto",top:0,bottom:0,scrollContainer:function(t){return ht([])},responsiveContainer:function(t){return ht([])},getSizingRow:function(t,e,o){return t.find("tbody tr:visible:first>*:visible")},floatTableClass:"floatThead-table",floatWrapperClass:"floatThead-wrapper",floatContainerClass:"floatThead-container",copyTableClass:!0,autoReflow:!1,debug:!1,support:{bootstrap:!0,datatables:!0,jqueryUI:!0,perfectScrollbar:!0},floatContainerCss:{"overflow-x":"hidden"}};var vt=function(){var n={},o=Object.prototype.hasOwnProperty;n.has=function(t,e){return o.call(t,e)},n.keys=Object.keys||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var o in t)n.has(t,o)&&e.push(o);return e};var r=0;return n.uniqueId=function(t){var e=++r+"";return t?t+e:e},ht.each(["Arguments","Function","String","Number","Date","RegExp"],function(){var e=this;n["is"+e]=function(t){return Object.prototype.toString.call(t)=="[object "+e+"]"}}),n.debounce=function(o,n,r){var a,i,l,s,d;return function(){l=this,i=arguments,s=new Date;var e=function(){var t=new Date-s;t").css("width",0).append(ht("
").css("max-width","100%").append(ht("").append(ht("
").append(ht("
").css("min-width",100).text("X")))));ht("body").append(t);var e=0==t.find("table").width();return t.remove(),e}return!1},mt=!t&&!wt,yt=ht(window),Tt=t&&window.matchMedia;if(!window.matchMedia||Tt){var e=window.onbeforeprint,o=window.onafterprint;window.onbeforeprint=function(){e&&e(),yt.triggerHandler("fth-beforeprint")},window.onafterprint=function(){o&&o(),yt.triggerHandler("fth-afterprint")}}function Ct(t){var e=t[0].parentElement;do{if("visible"!=window.getComputedStyle(e).getPropertyValue("overflow"))break}while(e=e.parentElement);return e==document.body?ht([]):ht(e)}function xt(t){window&&window.console&&window.console.error&&window.console.error("jQuery.floatThead: "+t)}function jt(t){var e=t.getBoundingClientRect();return e.width||e.right-e.left}function St(){var t=document.createElement("scrolltester");t.style.cssText="width:100px;height:100px;overflow:scroll!important;position:absolute;top:-9999px;display:block",document.body.appendChild(t);var e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}function zt(t,e,o){var n=o?"outerWidth":"width";if(l&&t.css("max-width")){var r=0;o&&(r+=parseInt(t.css("borderLeft"),10),r+=parseInt(t.css("borderRight"),10));for(var a=0;a http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")}return this.filter(":not(."+pt.floatTableClass+")").each(function(){var e=vt.uniqueId(),m=ht(this);if(m.data("floatThead-attached"))return!0;if(!m.is("table"))throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');bt=pt.autoReflow&&bt;var d=m.children("thead:first"),o=m.children("tbody:first");if(0==d.length||0==o.length)return pt.debug&&(0==d.length?xt("The thead element is missing."):xt("The tbody element is missing.")),m.data("floatThead-lazy",pt),void m.unbind("reflow").one("reflow",function(){m.floatThead(pt)});m.data("floatThead-lazy")&&m.unbind("reflow"),m.data("floatThead-lazy",!1);var y,T,n=!0,C={vertical:0,horizontal:0};vt.isFunction(St)&&(St=St());var f=0;!0===pt.scrollContainer&&(pt.scrollContainer=Ct);var x=pt.scrollContainer(m)||ht([]),j=0").css({display:"table-footer-group","border-spacing":0,height:0,"border-collapse":"collapse",visibility:"hidden"}),W=!1,i=ht([]),q=wt<=9&&!j&&I,c=ht(""),u=ht(""),p=m.children("colgroup:first"),h=!0;0==p.length&&(p=ht(""),h=!1);var v=ht("").css({display:"table-row","border-spacing":0,height:0,"border-collapse":"collapse"}),R=ht("
").css(pt.floatContainerCss).attr("aria-hidden","true"),M=!1,l=ht("
"),b=ht(''),w=ht([]),g=ht([]),E=ht([]),k=ht([]);l.append(b),m.prepend(p),mt&&(a.append(v),m.append(a)),c.append(u),R.append(c),pt.copyTableClass&&c.attr("class",m.attr("class")),c.attr({cellpadding:m.attr("cellpadding"),cellspacing:m.attr("cellspacing"),border:m.attr("border")});var t=m.css("display");if(c.css({borderCollapse:m.css("borderCollapse"),border:m.css("border"),display:t}),j||c.css("width","auto"),"none"===t&&(M=!0),c.addClass(pt.floatTableClass).css({margin:0,"border-bottom-width":0}),I){var s=function(t,e){var o=t.css("position"),n=t;if(!("relative"==o||"absolute"==o)||e){var r={paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight")};R.css(r),n=t.data("floatThead-containerWrap")||t.wrap(ht("
").addClass(pt.floatWrapperClass).css({position:"relative",clear:"both"})).parent(),t.data("floatThead-containerWrap",n),W=!0}return n};j?(i=s(x,!0)).prepend(R):(i=s(m),m.before(R))}else m.before(R);R.css({position:I?"absolute":"fixed",marginTop:0,top:I?0:"auto",zIndex:pt.zIndex,willChange:"transform"}),R.addClass(pt.floatContainerClass),U();var D={"table-layout":"fixed"},F={"table-layout":m.css("tableLayout")||"auto"},O=m[0].style.width||"",N=m.css("minWidth")||"";function A(t){return t+".fth-"+e+".floatTHead"}function Q(){var t=0;if(d.children("tr:visible").each(function(){t+=ht(this).outerHeight(!0)}),"collapse"==m.css("border-collapse")){var e=parseInt(m.css("border-top-width"),10);parseInt(m.find("thead tr:first").find(">*:first").css("border-top-width"),10)'),r.push("
"),a.push(ht("").css({display:"table-cell",height:0,width:"auto"}));r=r.join(""),n=n.join(""),mt&&(v.empty(),v.append(a),k=v.find("fthtd")),b.html(n),w=b.find("th"),h||p.html(r),g=p.find("col"),u.html(r),E=u.find("col")}return t}();return function(){var t=R.scrollLeft();g=p.find("col");var e,o,n,r,a=(e=m,o=g,n=k,r=wt,mt?n:r?pt.getSizingRow(e,o,n):o);if(a.length==s&&0=v+y?(o=0,P(),X(!1)):(o=y+v-u.top+s+(H?d:0),G(),X(!0)),n=g):j&&!I?(lv+y?(o=u.top-v,G(),X(!1)):(o=y,X(!0)),n=u.left+g-b);return{top:Math.round(o),left:Math.round(n)}}}}function Z(){var i=null,l=null,s=null;return function(t,e,o){if(null!=t&&(i!=t.top||l!=t.left)){if(8===wt)R.css({top:t.top,left:t.left});else{var n="translateX("+t.left+"px) translateY("+t.top+"px)",r={"-webkit-transform":n,"-moz-transform":n,"-ms-transform":n,"-o-transform":n,transform:n,top:0};r[/rtl/i.test(document.documentElement.dir||"")?"right":"left"]=0,R.css(r)}i=t.top,l=t.left}e&&function(){var t=zt(m,k,!0),e=z?S:x,o=e.length?jt(e[0]):t,n="hidden"!=e.css("overflow-y")?o-C.vertical:o;if(R.width(n),j){var r=100*t/n;c.css("width",r+"%")}else c.css("width",t+"px")}(),o&&Q();var a=(z?S:x).scrollLeft();I&&s==a||(R.scrollLeft(a),s=a)}}function _(){if(x.length)if(pt.support&&pt.support.perfectScrollbar&&x.data().perfectScrollbar)C={horizontal:0,vertical:0};else{if("scroll"==x.css("overflow-x"))C.horizontal=St;else{var t=x.width(),e=zt(m,k),o=ntable>thead").add(m.children("tbody,tfoot")):m.children("thead,tbody,tfoot")}})}),this}}(function(){var t=window.jQuery;return"undefined"!=typeof module&&module.exports&&!t&&(t=require("jquery")),t}()); \ No newline at end of file diff --git a/license.txt b/license.txt index 24777de..07bc51c 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2012-2017 Misha Koryak +Copyright (c) 2012-2018 Misha Koryak Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/package-lock.json b/package-lock.json index d16ca92..9f90ce8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "floatthead", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d77bb4e..3d5b5a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "floatthead", - "version": "2.1.2", + "version": "2.1.3", "description": "fixed table header plugin that works", "main": "dist/jquery.floatThead.min.js", "scripts": { @@ -21,6 +21,7 @@ "fixed table header", "table", "thead", + "the cat is cute", "floatThead", "scrolling table", "jQuery plugin"