Last active
August 29, 2015 14:07
-
-
Save Luxiyalu/3342baac7843e7d16ba7 to your computer and use it in GitHub Desktop.
AngularJS Directive: Follow Mouse Movement
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
# dependency: jQuery | |
app.directive 'followMousemove', -> | |
restrict: 'A' | |
($scope, $element, $attr) -> | |
$(document).mousemove (e) -> | |
$element.css | |
# specific number here could be modified | |
top: e.pageY | |
left: e.pageX | |
# be sure to turn off the listener on scope destroy | |
# because non-angular listeners needs to be manually cleaned up | |
$scope.$on '$destroy', -> | |
$(document).off('mousemove') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment