Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a behavior for exposing a mousemove event stream.
- Loading branch information
Josh Graber
committed
Nov 4, 2015
1 parent
abe54bd
commit 5194111
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |