Re:Mystery Rock 'Appears' in Front of Mars Rover
by runn1ng on Friday January 17, 2014 @01:34PM
(#7077540)
CSS has race conditions?
Re:Mystery Rock 'Appears' in Front of Mars Rover
by ehsanu1 on Friday January 17, 2014 @01:40PM
(#7077583)
It's JS, check the gist. The race condition is with image loading. I don't think CSS has race conditions, but someone please prove me wrong here :)
Re:Mystery Rock 'Appears' in Front of Mars Rover
by troels on Friday January 17, 2014 @02:41PM
(#7077967)
I suppose implementation could have, but since the language is declarative, I think that could rightfully be considered a bug.
Re:Mystery Rock 'Appears' in Front of Mars Rover
by runn1ng on Tuesday January 21, 2014 @06:48AM
(#7094677)
Oh all right, that makes more sense.
Psst. Discovery folks. You've got yourself a race condition. You're calculating a `margin-top` to center an image vertically irrespective of whether that image has loaded. You either need to explicitly set the width and height as attributes on the image (good for preventing reflow anyway) or hold off on calculating your dimensions until after the image has loaded. You could even just wait for window load (instead of DOMContentLoaded).
EDIT: Here's an untested, hacky fix. Not an ideal solution but concise and without having to change anything. https://gist.github.com/anonymous/c40e8baf679aad65cb2c