sticky-sidebar icon indicating copy to clipboard operation
sticky-sidebar copied to clipboard

Sticky bottom bug when the page refreshed at bottom

Open zom243 opened this issue 7 years ago • 3 comments

When the page refreshed at bottom, the sidebar will stick way above the container bottom line. It seems the problem is this sticky sidebar calculated the page dimension before the images loaded. So when the images loaded (images on content, because my images on sidebar have fixed dimension while the ones on content designed to be responsive) this will make the page getting taller and sticky sidebar stuck above the bottom. When the screen resized, sticky sidebar will recalculate the dimension and will work correctly.

Not that this is a big problem because people won't refresh page while at bottom page, but maybe this can be perfected.

zom243 avatar Feb 08 '18 13:02 zom243

You should put the code inside a $(window).load or window.onload call, so it doesn't run until all images have loaded. I'm surprised you don't have this issue even on initial page loads.

brouxhaha avatar Feb 28 '18 16:02 brouxhaha

@zom243 try to call updateSticky() method on your sticky sidebar object right after you initialize it. See if this solves your issue.

sfusato avatar Jan 02 '19 12:01 sfusato

init

window.stickySidebar = new StickySidebar('#sticky_sidebar');

and when the page refreshed at bottom

if (typeof window.stickySidebar !== 'undefined') window.stickySidebar.updateSticky();

worka avatar Jul 04 '19 01:07 worka