gss / engine

GSS engine
http://gss.github.io
MIT License
2.86k stars 105 forks source link

Gotcha - display:none w/ intrinsic measurements #41

Open jasonkuhrt opened 10 years ago

jasonkuhrt commented 10 years ago

When the page loads the layout is thus:

screen shot 2014-03-28 at 9 59 07 am

Then, given a tug on the window size (any which way), gss lays out correctly: screen shot 2014-03-28 at 9 59 09 am

See failing case at: http://jasonkuhrt.github.io/sandbox/

The gss code in question is:

body, html {width: 100%; height: 100%; margin: 0; padding: 0;}

html {
  font-size: 24px;
  text-align: center;
  font-family: Helvetica;
}

.box {
  center-x: == ::window[center-x];
  center-y: == ::window[center-y];
  width: <= ::window[width] / 2;
  height: == ::this[intrinsic-height];
  background: red;
  color: white;
}
jasonkuhrt commented 10 years ago

Has anyone observed this exact same layout quirk?

jiko commented 10 years ago

I tried this in Chrome and observed the same.

d4tocchini commented 10 years ago

Here's a JSFiddle of your example, it works there as it should.

Looks like it could be the

html:not(.gss-ready){ display: none; }

display:none kills measurement information so when GSS tries to measure the height of the button it gets 0, when the screen is resized measurements are valid and the button moves up by about half its height . Try opacity:0

d4tocchini commented 10 years ago

Whoops, use this JSFiddle link:

http://jsfiddle.net/v7u6N/7/

jasonkuhrt commented 10 years ago

@d4tocchini Ok, I updated the example at http://jasonkuhrt.github.io/sandbox/ and indeed it works fine if using the opacity: 0; technique.

Is this considered a valid gotchya (that just needs to be noted in a GSS guide) or should this be considered a bug?

d4tocchini commented 10 years ago

Unfortunately there's no way around this without completely ditching the DOM, so it's Gotcha not a bug.

Planning on adding a Gotcha section to the site...