It has been bothering me that the plugin required you to specify the dimensions of the image. The reason I wrote it that way was because the image wasn't loaded yet when it was added to the page, so we didn't have the dimensions. I have finally had the opportunity to enhance it to calculate those dimensions for you whether the image was preloaded or not.
The fix was to attach the javascript that gets the image size in a "load" event handler on the new image. Since it is added to the DOM every time, it will always be fired.
Enjoy the new version and let me know if you have any feature requests or bugs!
I rolled out version 0.3 on a site I am working on last night and found an annoying issue. I had to override the default settings in every call with the same new defaults. That wasn't cool.
So tonight is another release with a small but handy little addition to the plugin. You can now call $.curtainSetup(options) and override the default options. That means you can just add it once to your document ready handler and not have to keep passing in the options with every call.
My code that calls curtain is now a little cleaner, which makes me happy and everyone else appreciates, too.
When I first wrote the documentation for Curtain, it hit me that the plugin had a fatal flaw. I originally wrote it to append the curtain into the dom element being curtained. It seemed reasonable at the time. It made it such that I could easily keep track of what curtain belonged to what element without having to track ids or anything.
Well as it turns out, that was a big mistake. That implementation carried with it the "feature" of not being able to add it to elements that cannot accept a child div element or to elements that had an absolute position. I have wanted to use it on table rows a few times since I released it and finally had the chance this evening to redo the implementation.
If you upgrade to version 0.3, it will now append all the curtain elements to the body tag, so they are completely independent of the element being curtained. Each one receives a unique id, which is stored in the id attribute of the curtain and in a data element in the element being curtained. It actually makes the code a lot cleaner and the implementation a lot more robust.
With the new way of linking curtains to the curtained elements, I added a .curtain("get") function to allow easy access to the curtain in case you need it for some reason. I needed it for the tests and I can't imagine why you would want to access it in code, but it is there for you nonetheless.
On a side note, I did a little TDD and added the test for adding to absolutely positioned elements before fixing the bug. TDD rocks the house, BTW. If you aren't doing it, you should totally give it a try. Screw.Unit for javascript testing is awesome as well and fits really well with jQuery plugins. If you want to see an example of it in action, check out the spec directory under the project root on github. Just render the suite.html file in your browser to run the tests.