improve screen capture code to listen for transition end events