brandonaaron / jquery-cssHooks

Collection of cssHooks that work with jQuery 1.4.3+
Other
478 stars 80 forks source link

Multi-value properties (text-shadow, box-shadow, etc) #21

Open pdokas opened 13 years ago

pdokas commented 13 years ago

It would be good to support the CSS properties that can contain comma-separated values. A problem in doing so is that there's no defined name for these sub-values in the CSS specs. Names like textShadow0, textShadow1, … textShadowN seem reasonable enough. However, implementing them presents a significant architectural problem.

We'd need to populate $.cssHooks with each textShadowN value (and its subvalues, like textShadow3Color?) but obviously we can't just do that because N is unbounded. It seems like we need to dynamically create the necessary cssHook at the beginning of a get/set/animate call. I've studied the problem and it seems to require support from within jQuery itself but it's also seeming like going beyond reasonable scope.

Any thoughts? Is there need for this sort of thing? I mean, just imagine the fun that could be had on http://mothereffingtextshadow.com/ with such an ability ;)

tomgrohl commented 13 years ago

It would be good if someone wanted to changed say the third text shadow in a list of different text shadows.

Although certain browsers, like Opera, only allow a max of 6-9 text shadows. Safari 1 only supports one. It may be best to set a maximum yourself and test to see whether a browser supports 1 or multiple.

More info here (bottom of page): https://developer.mozilla.org/en/CSS/text-shadow

pdokas commented 13 years ago

Indeed. Safari only supported a single shadow until 4.0 as well. “Gecko (Firefox) theoretically supports infinite text-shadows (don't try it).” is a fun sentence.

The worry is that since there's no stated limit to number of shadows, in the spec or generally agreed-upon, we can't assume any specific cap. And without a cap there's no way to prepopulate all the necessary $.cssHooks values.