-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose vendor prefix in future version. #233
Comments
you know... i wasnt planning on doing this.. but that's a good idea. a really good idea. :) |
? EDIT: scroll down to see the revised API proposal,. |
Ideally it would be more like "-webkit-" so that it could be concatenated like Modernizr._prefix + "transition" My full design pattern looks something like: if(Modernizr.csstransforms) { Then in use that's something like (in Jquery):
On Apr 8, 2011, at 9:39 AM, paulirish wrote:
|
That helps. Thanks. |
One interesting snag with my model seems to be that setting "-ms-transform" is not accepted via JS. Seems that msTranform and "ms-transform" are, however. On Apr 8, 2011, at 9:51 AM, paulirish wrote:
|
I think we can't just generalize this because i need a property to test this against.. and always expecting a vendor prefix isnt futureproof. Might have to do something like....
|
Having just put this all to test in a real project, I found it necessary to determine & cache prefixes this way:
This was from http://leaverou.me/2009/02/find-the-vendor-prefix-of-the-current-browser/ and it works efficiently as a standalone. CSS syntax strings are only marginally useful and not reliable in Firefox or IE. Setting a css property as "-moz-transform" can fail, but MozTransform will work. Sadly, IE chooses to use a lowercase prefix, and while they do accept CSS syntax, they drop the leading hyphen. All told it's too nuanced to use. Closing the gap between storing prefixes as detected above and future-friendly end-use would be a utility method such as you propose (to pseudocode, where the prefix is cached):
This way, you return plain "transform" going forward, but for now you get back: WebkitTransform Thanks for considering this feature. It would be really useful in setting CSS3 properties. On Apr 9, 2011, at 11:20 AM, paulirish wrote:
|
I think either way we go with this, we’re excluding the other use case.
Why is this? I don’t understand why one would fail but the other method would work. Is this a Firefox-particular bug? I suggest that we expose the JS-oriented version (e.g. Webkit, Moz, O, ms…) since that’s always the environment in which the property will be used. If you want to use the property in a CSS composition, it’s an easy enough conversion: .toLowerCase() and surround it with hyphens. Done. |
it probably makes sense to expose the JS version.. also this would be wise because IE breaks spec and uses However it makes it difficult for the people who like to set a bunch of properties via
Also I want to point out this post http://leaverou.me/2009/02/find-the-vendor-prefix-of-the-current-browser/ which has a different technique and is generalized. basically it looks over every prop in the style object until it finds one that has a prefix.. and returns that. That is probably more expensive than what we do (requiring the property you're looking for.) but anyway... |
So yeah, to summarize.. we're looking to do an API like this:
Also we'll try to cache the prefix we find during test running so we dont have to test things twice.' Plz holler if you have a use-case that isnt satisfied by this. |
Funky use case: transition end events
There's also the chance that I'm using CSS properties setting a CSS property like transitionProperty
I don't think these warrant exposing which in |
One use case I would like for this to cater to is this:
|
This would be awesome. I'm currently doing this: var vP = ""; var transitionEnd = "transitionEnd"; if ($.browser.webkit) { vP = "-webkit-"; transitionEnd = "webkitTransitionEnd"; } else if ($.browser.msie) { vP = "-ms-"; } else if ($.browser.mozilla) { vP = "-moz-"; transitionEnd = "transitionend"; } else if ($.browser.opera) { vP = "-o-"; transitionEnd = "oTransitionEnd"; } Then something like: var cssArgs = {}; cssArgs[vP+"transform"] = "translate(100px,0px)"; animate($("#someID"),cssArgs); Which kinda sucks. |
@richbradshaw - Quick way for getting transition end event name might be to just set up some hashes
|
…example from desandro. thxx. ref #233
It's in. :) |
Nice! we were just discussing the need for it, and you fixed it already. Thanks. |
…e variant of your input Modernizr.prefixed('boxSizing') // 'MozBoxSizing' fixes Modernizr#233 Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style. Return values will also be the camelCase variant, if you need to translate that to hypenated style use: str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-');
…example from desandro. thxx. ref Modernizr#233
I love Modernizr because it allows me to do feature-based code branching. When setting CSS properties for transitions (and the like) in JS, it would be ideal if Modernizr exposed the appropriate browser prefix, since that's surely discovered in the course of its work.
The text was updated successfully, but these errors were encountered: