On this page I collect jQuery Plugins I have written, unless noted otherwise they are all released under WTFPL.
If my plugins make you happy, sad, angry or just thankful feel free to write me a mail: mail@saturnpolly.net.
Monitors the distance between the bounds of a given element and the current mouse position. See the demo.
$('#foo').monitorDistance(function(distance) {
console.log(distance);
if(distance<100)
return false;
}, {max:300});
This example monitors the distance to #foo, the callback will be only executed when the distance equals or is below 300.
monitorDistance expects at least one argument, the callback that is executed if the mouse is moved (and thus the distance changes).
You can pass an object literal as a second argument to set a minimum and/or maximum distance, you will only be notified if the distance lies within those boundaries.
The callback received the current distance as it's only argument. Inside of the callback this references the element that is beeing monitored. The callback can return false to indicate that the distance to this element should not be monitored anymore.
Any requirements imposed on the jQuery methods offset(), outerWidth() and outerHeight() also apply to this plugin.
So far this plugin has been tested with Firefox 3.5.3, Safari 4.0.3 and Opera 9.6.3. They all liked it :)
Since it does nothing fancy, other browsers should be fine, too.
Marks elements in a way that looks similar to what the selection tool in Photoshop does. See the demo.
$('#elem1').marker();
$('#elem2).marker({frameWidth:3, extraClass:'foo'});
$('#myButton').click(function() {
$('#elem1').marker(false); // remove
});
This example adds a standard marker and a marker width a custom width and additional class attribute value. The first marker is removed on click.
marker expects only one (optional) argument. This argument can either be false to remove the marker or an object literal for setting a custom frameWidth or additional class (extraClass). The class can be used to apply different image (shown in the demo).
Any requirements imposed on the jQuery methods offset(), outerWidth() and outerHeight() also apply to this plugin.
So far this plugin has been tested with Firefox 3.5.3, Safari 4.0.3, Opera 9.6.3 and IE8. They all liked it :)
Should be fine in other browsers as well.