-
Notifications
You must be signed in to change notification settings - Fork 235
Allow PIE to be invoked as a standalone JS library #19
Comments
If you do decide to do this please make the selector engine modular. E.g. Use MooTools or jQuery selector engines if they are already available on the page. If you do include a selector engine to include in the source, be sure to check the latest results of the SlickSec cross-library selector engine test suite. |
We would really love to see the standalone javascript feature. We're facing a problem using PIE in an IE browser control that loads content without setting its URL. Its URL remains about:blank, and any attempt to load HTC's results in access denied script errors. Exposing a javascript method sounds like a suitable workaround for us. Any idea how much work is left to complete this item, or what I can do to help? |
@hbchai: Most of the work is already done, and the build script now produces a PIE.js in addition to PIE.htc. The part that is remaining is deciding what public API is going to be available for hooking up elements. Right now, there are only two public methods: PIE.attach and PIE.detach, both of which accept a single element reference as argument (see http://github.com/lojjic/PIE/blob/master/sources/PIE_API.js). This is obviously very limited and pretty inconvenient for users. We definitely want something more powerful and convenient; I see a couple decent options: A) Expose something similar to what DD_roundies does, where the user calls a public method passing it a selector or set of selectors. A downside to this is that the user has to maintain the PIE initialization code in JS separately from the CSS. B) Have users invoke a CSS expression which initializes PIE on the element (PIE would then clear the expression right away to prevent continual evaluation) -- this would look something like: behavior:expression(PIE.attach(this)); It's of course possible to do both. If anyone has better suggestions I'd love to hear them. :) I should also mention the big downside to any of these approaches: unlike .htc there is no way I'm aware of to automatically clean up the PIE rendering when the target element is removed from the DOM. That would have to be a manual process and would make PIE pretty tough to use in highly dynamic DOMs. |
The HTC approach is certainly the most elegant, and I wish we could use it. :) Approach B) certainly sounds interesting as a more user-friendly way of exposing the API. Behaviors were completely new to me before encountering PIE - and now this expression syntax is completely fresh too. I tried a simple test using PIE.attach() from the latest code. The div that I'm testing gets rounded borders, but also unexpectedly turns black (at least in IE8, so far). Is this due to a different issue? Here's my test:
|
Try using a color other than 'orange'... VML only supports a subset of CSS color keywords and I think orange is not one of them. See if a hex value works. |
You're right - changing the color worked! Thanks! |
Regarding my prior suggestion of using css expressions to invoke the JS attach method (option B)... I just remembered that expressions are not supported in IE8 standards mode, so this is not a viable option for users. |
Any word on the development of a non htc version of css3pie? I almost always use a CDN for asset delivery and htc files do not work on an external domain. |
@JamieS: http://css3pie.com/documentation/pie-js/ -- it's been included since beta3. The API is currently very rudimentary, so this ticket is just kept open to track improving that. But it should be usable. |
Great! I'll add feedback today if I see a need. Thanks for the quick reply! |
I'm closing this as finished, as the standalone JS has been part of the build since beta3 and I think the current API, though extremely simplistic, seems to be sufficient for most needs. |
Making PIE run as a .htc behavior has several advantages: users don't have to write any JS, the FOUS is avoided because the behavior is applied as soon as each element is ready, automatic cleanup when the element is unbound, etc.
However it might be useful, especially for third party libraries, to be able to invoke PIE as a pure .js file, without the .htc wrapper. We could expose a PIE.applyTo() element which accepts an element reference or maybe a selector, and a corresponding method to remove it.
We're probably pretty close to being able to do this. We'd have to rework a few things, like the fact that element-specific values are stored as local variables in the .htc would have to be changed so they are stored on the element itself or using a data hash with id indexes like jQuery does. We'd also have to attach the event listeners programatically, and make sure to clean them up on unload to prevent memory leaks.
The resulting .js file would be an addition to the PIE distribution; the .htc would still be the preferred method of attachment for the above stated reasons.
The text was updated successfully, but these errors were encountered: