fix the bug on resizing the viewport