0

I am writing a layout algorithm that sizes and positions a list of images within a container similarly to Flickr's justified layout.

enter image description here

After running through some measurements and resizing the list items, I position each item absolutely using left and top. The calculations are based on the width of the container. If there are more items than can fit on the page, scroll is triggered. In some browsers, this means the window, and therefore the container is reduced in width to make space for the scrollbar. This means that my layout calculations are now incorrect and the list items overlap the scrollbar by the width of the scrollbar.

I already listen for the window's resize event and re-layout the list if the window width changes, but given that there is no event when a scrollbar appears I have no way to trigger a new layout. It seems that my only option is to poll for this case.

Is there any other approach I can use?

Undistraction
  • 42,754
  • 56
  • 195
  • 331

0 Answers0