Implements mouse capture as an AngularJS directive.