Fix bug when resizing