All Projects → websanova → mousestop

websanova / mousestop

Licence: other
jQuery mousestop plugin

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language

mousestop.js

A jQuery mousestop plugin to compliment other mouse events such as mousemove, mouseout and mouseout coming in at ~1Kb minified.

The mousestop event was created using the jQuery Special Events API and therefore can be binded like any other event.

Examples

The most basic usage is to pass in the callback for a stop event.

$('#el').mousestop(function() {
    console.log("stopped")
});

We can also pass the delay time in the second parameter to specify the amount of time to delay before a stop triggers. The default is 300 milliseconds

$('#el').mousestop(2000, function() {
    console.log("stopped")
});

There is also a settings parameter called timeToStop. This parameter specifies a window of time that the stop event has to occur. After that time the stop event will no longer trigger whatsoever. Leaving the value unset or setting it to null will deactivate this timer.

$('#el').mousestop({timeToStop: 1000}, function() {
    console.log("stopped")
});

To set both a delay and a settings parameter.

$('#el').mousestop({delay: 400, timeToStop: 1000}, function() {
    console.log("stopped")
});

We can also bind and trigger the event as you would expect with any other element.

$('#el').bind('mousestop', function(){
	console.log('stopped');
});

$('#el').trigger('mousestop');

Since we are using the jQuery special API we can also use the on method to bind the event as well.

$('#el').on('mousestop', function(){
	console.log('stopped');
});

Grunt.js

If you want to use Grunt you will need to install the required plugins locally using npm install in the root folder of the project. If you need to setup Grunt on your system you can follow this Setting up Grunt.js guide.

Resources

License

MIT licensed

Copyright (C) 2011-2012 Websanova http://www.websanova.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].