No reliable way to determine if a CSS property is "auto" #16

Open
gnarf opened this Issue Oct 27, 2011 · 4 comments

Projects

None yet

4 participants

@gnarf
gnarf commented Oct 27, 2011

As the maintainer of an animation / effects library, this issue has been a thorn in my side multiple times. Trying to determine if an element is positioned using left, top or right, bottom or some combination of all of them is currently impossible to do in a cross browser way. The "Computed Style" of right and bottom in webkit will return auto but FF spoils the day by returning an actual px value (which by my interpretation is actually the correct value to return).

After animating elements, my code must either assume that the element was positioned left and top since there is no way to determine what the initial positioning actually was, or accept some sort of configuration parameter to tell it which to use. This means that after running my effect code on your arbitrary div that was positioned using right and bottom it will no longer be positioned relative to the bottom right as its relative container resizes.

The issue of knowing if a CSS property is auto probably has more uses than just left and top. I could see width and height also being useful to know if it is auto or specifically set.

Specific Issues

  • Makes it impossible to detect if an element is positioned with right and bottom

Specific Suggestions

  • isCSSAuto( property ) - Some method (be it on the computed style object, or somewhere else) could be provided to determine if a style property is auto before computation.
  • right and bottom shouldn't return auto on a computed style object.
@wycats
Contributor
wycats commented Oct 31, 2011

@gnarf37 have you also found it to be a problem that there's no reliable way to getBoundingClientRect after transform in all browsers?

@gnarf
gnarf commented Nov 1, 2011

@wycats TBH - I haven't even looked into potential issues with transform properties yet, so not yet, but it sounds like that would also be useful.

@scottgonzalez
Collaborator

This was also a problem for us in the jQuery UI Accordion redesign. We wanted to determine whether all panels should be the height of the tallest panel or the height that the accordion element was before applying the JavaScript and styles. This would be based on whether the element had an explicit height or an auto height. Since we couldn't determine if the element had auto height, we had to add an option.

@leobalter
Collaborator

@gnarf should we keep this issue? Can you provide an example to verify this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment