Skip to content

This plugin tracks cursor position values. Like position on x or y axis and angle. Returned values only applies to the called element. The plugin is dependent on jQuery.

License

Notifications You must be signed in to change notification settings

tomislavjezidzic/cursor-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

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.


Author: Tomislav Jezidžić
Contributor: Mario Novoselec
Year: 2017
Size: ~4Kb

About

This plugin tracks cursor position values. Like position on x or y axis and angle. Returned values only applies to the called element. The plugin is dependent on jQuery.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published