Fix: One column bug in some cases.

This script sometimes gets the wrong width of the container. Because of this, the number of columns is calculated incorrectly.

in my case I solved this problem by minor change resize function: