game-prototypes icon indicating copy to clipboard operation
game-prototypes copied to clipboard

Object Containment

Open thinkt4nk opened this issue 14 years ago • 0 comments

Ok, I added support for selector containment, easily used like the following. You can see it illustrated in the default example of my fork. The cat box is bordered by 1px solid red.

move('#cat') .add('left', Math.random() * 30 | 0) .add('top', Math.random() * 30 | 0) .contain('#cat_box') .end()

I also added converse property translation. The converse translation works when I do something like the following:

move('#cat') .add('left', Math.random() * 30 | 0) .add('top', Math.random() * 30 | 0) .contain({ bottom : '+30-50' }) .end();

Basically, it'll convert the bottom containment to the appropriate top, since that's the prop that's set in the Move object. In this case, you would be contained to the 'top' equivalent of 30 to 50 px from the bottom.

This code might need some cleaning up, and I'm totally open to suggestions.

thinkt4nk avatar Aug 31 '11 22:08 thinkt4nk