daniel-nagy / fixed-table-header

Fixed table header directive.
MIT License
88 stars 36 forks source link

fix-head calculates invalid header width, only fixes upon clicking header #20

Open Syntaf opened 7 years ago

Syntaf commented 7 years ago

I'm trying to use fixed-table-header in conjunction with a couple other modules, but it seems fix-head calculates it's header width well before the other elements kick in. If I click on anything else within the page, fix-head moves into the correct position

Is there anyway to force-refresh the fix-head header calculation at the end of a controller?

ghost commented 7 years ago

I am also facing the same Issue, after the table load the header cell is moved to reposition.

zhukovRoman commented 7 years ago

@Syntaf i am get some issue and i added next code for recalculating headers cells width:

$timeout () -> window.dispatchEvent(new Event('resize')) , 0

it trigger resize event for window and call recalc method form lib. It is terrible, but works

Syntaf commented 7 years ago

@zhukovRoman Awesome!

zhenya2224 commented 7 years ago

@Syntaf i am get some issue and i add next code for recalculating headers cells width:

$timeout () -> window.dispatchEvent(new Event('resize')) , 0

it trigger resize event for window and call recalc method form lib. It is terrible, but works.

Roman, can you please provide more details, how this method can be used. Your code should be in controller or fixed-table-header.min.js

UPD $timeout(function() { $window.dispatchEvent(new Event("resize")); }, 100); in controller did the trick

zhukovRoman commented 7 years ago

@zhenya2224 You are right! In my case, I call $timeout () -> window.dispatchEvent(new Event('resize')) , 0 in controller method, which is toggle some block on the page.

You can use 0 delay $timeout (only Angular timeout with $), because it was call after repainting.

zhenya2224 commented 7 years ago

Roman, I would be grateful for advice or solution, the problem is the header blinks while implementing $timeout(function() { $window.dispatchEvent(new Event("resize")); }, 100);

I made the value 0, it made it worse, it takes more time to recalculate resize event. timeout 100 works, but it creates blinking when page loads.