Fix the calculation of rail size.

Only consider the elements which are visible.