bigspotteddog / ScrollToFixed

This plugin is used to fix elements on the page (top, bottom, anywhere); however, it still allows the element to continue to move left or right with the horizontal scroll.
http://bigspotteddog.github.com/ScrollToFixed/
MIT License
1.81k stars 531 forks source link

ScrollToFixed for <tr> element #112

Open alfreddagenais opened 10 years ago

alfreddagenais commented 10 years ago

I have recently have a issue with your plugin. I have try to implement for <tr> attribute. In my code I have many <td> inside this <tr>. Colpan and other <table> features

In my code is simply :

$('tr').scrollToFixed({
                limit           : $(this).parent().offset().top + $(this).parent().outerHeight(true) - 10 - $(this).outerHeight(true)
 });

In line 124 of jquery-scrolltofixed.js I have add this few lines :

// Set data display for TR
if( !spacer.attr('data-display') && target.is('tr') ){
 spacer.attr('data-display', target.css('display') );
}

// Set the spacer to fill the height and width of the target
// element, then display it.
spacer.css({
  'display' : ( spacer.attr('data-display') && target.css('display') != 'none' && spacer.attr('data-display') != target.css('display') ? spacer.attr('data-display') : target.css('display') ),
  'width' : target.outerWidth(true),
  'height' : target.outerHeight(true),
  'float' : target.css('float')
 });

And for now every thing is fine. The problem I have discover, it's when the scrollbar go down and up many times, the <div>. created after <tr> have a display = "block" some times... But in this case, the display should be "table-row", because the <div> replace <tr>. So I have added a init value of the display to <div>.

bigspotteddog commented 10 years ago

Thanks! I will look at a way to add this to the plugin.