Added support for the events beforeShow, show, beforeHide, hide. Removed onTransitionEnd event. Optimised code further