Skip to content

Safari + cssStickyHeaders + Caption, makes table grow to infinity #1405

@TheSin-

Description

@TheSin-

not sure why, but with a caption, $table.height(); starts to grow by a multiple of scroll size after the height of caption. This seems to fix it but I haven't tested it outside of safari nor do I know if it's the best fix for this. I basically set a var tableH and use that till we pass a certain point. At the bottom of the table I get a little jumpiness but it corrects it's self, it's better then scrolling into infinite whiteness ;)

diff --git a/js/widgets/widget-cssStickyHeaders.js b/js/widgets/widget-cssStickyHeaders.js
index 07ed0f66..513ddcd9 100644
--- a/js/widgets/widget-cssStickyHeaders.js
+++ b/js/widgets/widget-cssStickyHeaders.js
@@ -29,6 +29,8 @@
                                $parent = $table.parent().closest('table.' + ts.css.table),
                                $parentThead = $parent.length && ts.hasWidget($parent[0], 'cssStickyHeaders') ? $parent.children('thead') : [],
                                borderTopWidth = ( parseInt( $table.css('border-top-width'), 10 ) || 0 ),
+                               // Fixes for safari
+                               tableH = $table.height(),
                                lastCaptionSetting = wo.cssStickyHeaders_addCaption,
                                // table offset top changes while scrolling in FF
                                adjustOffsetTop = false,
@@ -71,6 +73,12 @@
                                        adjustY = $table.offset().top;
                                }
 
+                               // Fix for safari, when caption present, table
+                               // height changes while scrolling
+                               if ($win.scrollTop() < $caption.outerHeight(true)) {
+                                       tableH = $table.height();
+                               }
+
                                var top = $attach.length ? $attach.offset().top : $win.scrollTop(),
                                // add caption height; include table padding top & border-spacing or text may be above the fold (jQuery UI themes)
                                // border-spacing needed in Firefox, but not webkit... not sure if I should account for that
@@ -78,7 +86,7 @@
                                        ( parseInt( $table.css('padding-top'), 10 ) || 0 ) +
                                        ( parseInt( $table.css('border-spacing'), 10 ) || 0 ),
 
-                               bottom = $table.height() + ( addCaptionHeight && wo.cssStickyHeaders_addCaption ? captionHeight : 0 ) -
+                               bottom = tableH + ( addCaptionHeight && wo.cssStickyHeaders_addCaption ? captionHeight : 0 ) -
                                        $thead.height() - ( $table.children('tfoot').height() || 0 ) -
                                        ( wo.cssStickyHeaders_addCaption ? captionHeight : ( addCaptionHeight ? 0 : captionHeight ) ),
 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions