Correctly handle resize events.