Fix a bug in fixStickyHeader, allow to use `width` style on fixed cells
parent
2ba24b71eb
commit
c465fb4ed3
|
@ -1,7 +1,7 @@
|
|||
// Simple Sticky Header and Column implementation for HTML tables
|
||||
// (c) Vitaliy Filippov 2016
|
||||
// License: MPL 2.0+
|
||||
// Version: 2016-08-15
|
||||
// Version: 2016-08-18
|
||||
|
||||
// USAGE:
|
||||
// makeStickyHeaders(table): add sticky header and footer to table
|
||||
|
@ -79,13 +79,14 @@ window.makeStickyHeaders = function(table)
|
|||
for (var i = 0; i < rs[0].children.length; i++)
|
||||
{
|
||||
var e = rs[0].children[i];
|
||||
e._oldWidth = e.style.width;
|
||||
e._sticky = true;
|
||||
e.style.position = 'absolute';
|
||||
e.style.width = w[i]+'px';
|
||||
e.style.height = h+'px';
|
||||
e.style.left = l[i]+'px';
|
||||
e.style.display = 'block';
|
||||
e.style.zIndex = '1';
|
||||
e._sticky = true;
|
||||
}
|
||||
// Try to minimise reflows: (1) make some changes
|
||||
for (var i = rs.length-1; i >= 0; i--)
|
||||
|
@ -97,7 +98,7 @@ window.makeStickyHeaders = function(table)
|
|||
var e = rs[i].children[0];
|
||||
var d = e.cloneNode(true);
|
||||
d.style.visibility = 'hidden';
|
||||
e.parentNode.insertBefore(d, e.nextSibling);
|
||||
rs[i].insertBefore(d, e.nextSibling);
|
||||
if (i != 0)
|
||||
{
|
||||
e.style.position = 'absolute';
|
||||
|
@ -124,6 +125,7 @@ window.makeStickyHeaders = function(table)
|
|||
if (!rs[i].children.length)
|
||||
continue;
|
||||
var e = rs[i].children[0];
|
||||
e._oldWidth = e.style.width;
|
||||
e.style.height = hs[i]+'px';
|
||||
e.style.width = w[0]+'px';
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ window.fixStickyRows = function(table, trs, nocols)
|
|||
d = e.cloneNode(true);
|
||||
d.className = d.className.replace(' _scri'+table._scri, '');
|
||||
d.style.visibility = 'hidden';
|
||||
d.style.width = '';
|
||||
d.style.width = e._oldWidth;
|
||||
d.style.height = '';
|
||||
d.style.position = '';
|
||||
d.style.display = '';
|
||||
|
@ -265,24 +267,27 @@ window.fixStickyHeader = function(table, nocols)
|
|||
var sr = table._sizerow;
|
||||
while (sr.children[1])
|
||||
sr.removeChild(sr.children[1]);
|
||||
var e, renew = false;
|
||||
var b, e, renew = false;
|
||||
for (var i = 0; i < tr.children.length; i++)
|
||||
{
|
||||
e = tr.children[i];
|
||||
if (!e._sticky)
|
||||
b = tr.children[i];
|
||||
e = b.cloneNode(true);
|
||||
if (b._sticky)
|
||||
{
|
||||
if (i == 0)
|
||||
e.className = e.className.replace(' _scri'+table._scri, '');
|
||||
e.style.position = '';
|
||||
e.style.width = b._oldWidth;
|
||||
e.style.height = '';
|
||||
e.style.left = '';
|
||||
e.style.display = '';
|
||||
e.style.zIndex = '';
|
||||
if (i == 0)
|
||||
i++;
|
||||
}
|
||||
else
|
||||
renew = true;
|
||||
e = e.cloneNode(true);
|
||||
if (i == 0)
|
||||
e.className = e.className.replace(' _scri'+table._scri, '');
|
||||
e.style.position = '';
|
||||
e.style.width = '';
|
||||
e.style.height = '';
|
||||
e.style.left = '';
|
||||
e.style.display = '';
|
||||
e.style.zIndex = '';
|
||||
sr.appendChild(e);
|
||||
if (e._sticky && i == 0)
|
||||
i++;
|
||||
}
|
||||
if (renew)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue