cursor meter

Measure distance traveled by cursor

Your cursor has traveled: meters.

Total distance traveled on this website: meters.


Basic initialization:

Basic initialization will attach to elements with ids #current-distance and #total-distance:

					var cursorMeter = $.cursorMeter();

You can destroy it:

					var data = cursorMeter.destroy();

It will return data object in following format:

Available options:

All options are optional but may significally change plugin behaviour.

				// current distance selector string
				currDistSelector: '#current-distance',
				// total distance selector string
				totalDistSelector: '#total-distance',
				// accuracy integer from 1 to 10 (1 = 0.1 second)
				refreshRate: 1,
				// statistics URL (used for permanent stats)
				updateUrl: null,
				// automatically round and add unit name (cm, m and km)
				autoUnitsConverter: true,
				// callback when data updated
				onUpdate: null,
				// callback custom numbers converter
				converter: null,
				// base unit returned (only when not using autoUnitsConverter)
				unitsBase: 'cm'			

Example code used to init this website:

				$(function() {
					// cursor meter
					var cursorMeter  = $.cursorMeter({
						updateUrl: 'php/odometer.php', 
						autoUnitsConverter: false, 
						unitsBase: 'm'});

Additional resources:

Odometer effect as can be seen on top of this website is not included in my plugin.

To obtain such effect simply copy patched version of odometer script.

Rest of its resources and instruction can be found here.


Example of statistics API can be found in php directory of downloaded package (written in PHP).