duckduckgo / zeroclickinfo-spice

DuckDuckGo Instant Answers based on JavaScript (JSON) APIs
https://duckduckhack.com/
Other
548 stars 942 forks source link

Timer: Somehow the layout was broken? #959

Closed moollaza closed 10 years ago

moollaza commented 10 years ago

I saw this happen once on DuckPAN but didn't think anything of it. Just happened again on the live site but I can't seem to re-create the problem image

Seems like a timing issue of sorts? Like the elements on the page haven't been created or don't have their full width yet..

//cc @mattr555 @jagtalon @russellholt

mattr555 commented 10 years ago

@moollaza I experienced this as well...but it's hit or miss. There might be race-condition media queries or something.

chrismorast commented 10 years ago

I got this too. Had to refresh half a dozen times for it to correct itself.

moollaza commented 10 years ago

@chrismorast hmm that's odd, we definitely need to find the cause and fix it then if it's occurring often

jagtalon commented 10 years ago

@bsstoner is right about that one.

mattr555 commented 10 years ago

It looks like the div that holds the time is interfering somehow. If you take the display: none off of that div, you get: 2014-07-15--1405433747_588x209_scrot

I can reproduce this error consistently on an iPad. I also found that if I switch to images, then back to the timer, the problem will correct itself. It does appear to be something with the timing. Should everything be enclosed in a $(document).ready()?

I found that this worked, will PR:

//wait for the document to load before displaying things
//this makes sure the divs display at the right time so the layout doesn't break
//this fixes #959
$(document).ready(function(){
   $('#timer_buttons').css('display', 'inline-block');
   $timer_input.css('display', 'inline-block');
});