refactoring animation events to make legend interactive