updated code to fire leave, enter and resize in correct order