sometimes offsetWidth returns 0

I find it is better to initialize it on the first click of the user.