Converting a jQuery plugin to work on all objects, not just the DOM
- by Jon Winstanley
I am using the jQuery physics plugin for a pet project I am working on.
The plugin enables the moving of DOM objects in realistic ways using velocity, gravity, wind etc.
However I want to use the plugin to calculate where objects are to be placed inside a canvas element, not DOM object.
How do I change the plugin script to work for ANY object with 'top' and 'left' properties rather than only working with DOM objects found with a jQuery selector?
Currently the script functions look like this:
jQuery.fn.funname = function() {
return this;
};