开发者

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜