Converting a jQuery plugin to work on any object, not just DOM objects

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;
};

Answers


// line 172 jquery.physics.js
if (!params.position) this.position = new $.Vector(parseFloat($(this).css('left')),parseFloat($(this).css('top')));

Need Your Help

How to make QTMovie play file from URL with forced (MP3) type?

objective-c cocoa mp3 qtkit progressive-download

I'm using QTKit to progressively download and play an MP3 from a URL. According to this documentation, this is the code I should use to accomplish that:

Removing the "box" of a checkbox in css

html css

I am trying to remove the actual box of a checkbox field, and just make the text clickable. How can I do this with JS and css? I started using buttons, but I switched to checkboxes because the "...