LeaVerou / dabblet

An interactive CSS playground
http://dabblet.com
818 stars 148 forks source link

Length previewer misbehaving #181

Open GeorgeTzellis opened 12 years ago

GeorgeTzellis commented 12 years ago

Hover over a 500px token, and within 300ms, hover over a 5px token. The length previewer appears even though it shouldn't (500px token is previewable, 5px isn't).

This happens because the previewer's validity is judged by its offsetWidth (previewer.js#L135). offsetWidth reflects the previewer's width at exactly the time it is requested, and when that time is between a transition of 500px to 5px, the previewer will return a false validity check.

Note that this issue and #153 have similar results, but different causes.

LeaVerou commented 12 years ago

Could be easily fix if instead of checking offsetWidth we parse the length. However, that means we're replacing one simple line of code with several. Is it worth it? (The question is not rhetorical)

GeorgeTzellis commented 12 years ago

Parsing the length would require too much work for me. Between px, in, pc, pt, cm, mm previewers, I'd rather spend my time elsewhere.

I had a much simpler approach in mind. The browser does the parsing for me, then I just read the result. We know the previewer's intended length. Set that onto a

#proxy {
	display: none; 
	transition: none;
}

and base the previewer's validity on getComputedStyle(proxy).width.