cursor_tracker
v1.1.0
Published
This plugin tracks cursor position values. Like position on x or y axis and angle. It's dependent on jQuery.
Downloads
3
Maintainers
Readme
Cursor tracker
This plugin tracks cursor position values. Like position on x or y axis and angle. Returned values only applies to the called element. This plugin is dependent on jQuery.
git link
Guide
Example
HTML
<body>
<div class="container">
</div>
</body>
or
<body>
<div class="container" data-dec="1">
</div>
</body>
data-dec="1" means that returned value will be with one decimal point (format x.x). Default value is 2 (format x.xx).
JS
$(".container").cursor('click', function(values){
console.log(values.angle);
});
Click (or any other event) will return cursor position value in degres.
Attributes
angle -(degres) in relation to the center of the element
angleRad -(radians) in relation to the center of the element
xAxis -(percentages) cursor position in relation to the left top corner of the element
yAxis -(percentages) cursor position in relation to the left top corner of the element
xAxisCentered -(percentages) cursor position in relation to the center of the element
yAxisCentered -(percentages) cursor position in relation to the center of the element
corner -corner of the element -returned value is in format [0, 0, 0, 0] and it represents [left top, right top, left bottom, right bottom]. A corner where the cursor is, will return the value 1 while other will be 0.