Skip to content

Commit

Permalink
Add a behavior for exposing a mousemove event stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Graber committed Nov 4, 2015
1 parent abe54bd commit 5194111
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/behaviors/behaviors.module.js
Expand Up @@ -2,7 +2,10 @@

var angular = require('angular');

var mouseOverModule = require('./mouseOver/mouseOver');

exports.moduleName = 'exp-ang.behaviors';

angular.module(exports.moduleName, [
mouseOverModule.moduleName,
]);
22 changes: 22 additions & 0 deletions js/behaviors/mouseOver/mouseOver.js
@@ -0,0 +1,22 @@
'use strict';

var angular = require('angular');
var Rx = require('rx');

exports.moduleName = 'exp-ang.behaviors.mouseOver';
exports.directiveName = 'eaMouseOver';

function mouseOverDirective() {
return {
restrict: 'A',
link: function(scope, element, attributes) {
var eventStream = Rx.Observable.fromEvent(element, 'mousemove');

// Use the value of the eaMouseOver attribute as the name to save to on the scope
scope[attributes.eaMouseOver] = eventStream;
},
};
}

angular.module(exports.moduleName, [])
.directive(exports.directiveName, mouseOverDirective);

0 comments on commit 5194111

Please sign in to comment.