Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12081 closed bug (cantfix)

jQuery.height() versus style.height inconsistent in Webkit with a transition.

Reported by: jaxesn@… Owned by: jaxesn@…
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:


When a transition is in place, in Chrome/Safari, the elm.style.height returns a different value than $elm.height(), right after setting the height property. In Firefox, either access method returns the value which was just set. I'm not sure which behavior is actually correct and/or its even a bug in jQuery or the browsers themselves. Tested with 1.7.2 and the lastest git.


In the fiddle example, if the transition is removed, the functions return the same value. Also, if using a setTimeout longer than the transition time of 2s, the output is the same.

Change History (4)

comment:1 Changed 11 years ago by dmethvin

Owner: set to jaxesn@…
Status: newpending

Both seem correct. You are asking jQuery the current height of the element, which is 0px since you just asked Webkit to start transitioning the property a few microseconds earlier in the same thread. I guess it might have gotten to 1px or 3.72px but 0px is an acceptable answer.

If you ask what the value of the property is, well then yes, it will dutifully parrot out the value you just recently assigned.

What values were you expecting?

comment:2 Changed 11 years ago by jaxesn@…

Status: pendingnew

I would expect the values to be the same between browsers, but I certainly see your logic. The issue came up because shortly after the height gets set, the $(body).height(), which is "missing" the 40px, is used to resize the page and the difference between the browsers became a problem.

Its trivial to workaround, but because of the inconsistency, I thought it might be worth pointing out in case anyone had seen it before or runs into again.

comment:3 Changed 11 years ago by dmethvin

If you tried to use the body height while it's still growing due to the transition effect, I think that's another case where it's hard to say what the precise value would be--jQuery or not. What value would you want the body height to reflect at, say, 1/2 second into the transition?

I guess what I'm getting at is, if there's not a clear logical answer then it's probably best not to ask the question. :) We can try to enshrine some answer but that doesn't seem wise.

comment:4 Changed 11 years ago by mikesherov

Resolution: cantfix
Status: newclosed

We can't reliably fix this anyway. This is a dupe, but I can't find the dupe at the moment, but this is a cantfix.

Note: See TracTickets for help on using tickets.