fixes invalidateLayout and resize events