implement pre_transition and post_transition callbacks

To use in: https://github.com/gizmag/gizmag/pull/126