Converting a jQuery plugin to work on all objects, not just the DOM

Posted by Jon Winstanley on Stack Overflow See other posts from Stack Overflow or by Jon Winstanley
Published on 2010-04-06T14:51:32Z Indexed on 2010/04/06 23:23 UTC
Read the original article Hit count: 305

Filed under:
|
|

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;

};

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about plugins