🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

A Cursor Tracker built using jQuery that keeps track of the current cursor position and angle on mouse move.

cursor

Documentation

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.

npm module

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.

DEMO

DEMO 2


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

You May Also Like