jquery - Table with SlideToogle Randomly Jerky -


i have table quite few rows. , jquery expand collapse rows. appears start ok , after short while find animation jerky, jumpy.

http://jsfiddle.net/felix00111/6jesxoxk/8/

below jquery

$('tr.main-parent')     .css("cursor", "pointer")     .click(function () {      var $children = $(this).nextuntil($('tr').not('.sub'));      if ($children.find(':visible').length) {         $children.find('td > div, td').slideup(1200);     } else {         $children.filter('.parent').find('td > div, td').slidedown("slow");     } }); $('tr[class^=child-]').find('td > div, td').hide();  $('tr.parent')     .css("cursor", "pointer")     .click(function () {     var $children = $(this).nextuntil($('tr').not('[class^=child-]'));     $children.find('td > div, td').slidetoggle(1200); }); $('tr.sub').find('td > div, td').hide() 

;

any ideas ? ive tried hard setting widths still continues.

thanks,

in nutshell, solution requires way resources, reason jumpiness.

you're not using efficient way of selecting elements, looking through such massive amount of elements isn't easy task cpu. , you're animating multiple elements simultaneously non-hardware-accelerated animation. jquery animations aren't efficient, multiple elements, it's no wonder pc struggling animation.

to make faster select needs shown or hidden, consider creating table within each row. way use .slideup() (if that's want use) on inner table instead. realize that's not same effect, imo nonetheless , make smoother. here's mean:

<table>     <thead>         <tr>             <th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th><th>xyz</th>         </tr>     </thead>     <tbody>         <tr>             <td>xyz</td>             <td>xyz</td>             <td colspan="18"><!--your inner table here--></td>         </tr>         <!-- more rows -->     </tbody> </table> 

then, inner table can 18 cells wide (or howmany every had...). can animate one element, instead of whole bunch. plus, selecting element much faster, because it's right inside element clicked on.

this may enough, , jquery animation might smooth alterations. , it's understandable if don't want deal css transitions, because require fixed height elements height you're animating. css transitions hardware accelerated, perform better.

you might want use .stop() function on elements before animating them, if end using jquery. way new animation requests aren't queued, instead current animations stopped , new 1 start instantly.

if don't want use css animations , jquery still seems slow, construct own animation using window.requestanimationframe(), hardware accelerated , make smoother animations.

or, use animation library support hardware acceleration, have same performance benefits using css. 1 option velocity.js witch works in conjunction or without jquery, has same syntax , has support things jquery doesn't support, transforms.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -