Fixed bug in resize event