Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of members in constraint declaration matters. Why? #199

Open
oslego opened this issue Aug 21, 2015 · 2 comments
Open

Order of members in constraint declaration matters. Why? #199

oslego opened this issue Aug 21, 2015 · 2 comments

Comments

@oslego
Copy link

oslego commented Aug 21, 2015

According to the docs, the constraints are two-way. Yet the order in which members are declared seems to matter.

For example:

#logo[top] == #container[top] + 64;

yields a different result from

#container[top] + 64 == #logo[top];

The latter yields the expected layout, but it is far less readable and intuitive than the former.
I've seen this swapped order in examples in the docs as well. Why is this?

Live example:
http://codepen.io/oslego/pen/WvqKXq

@andering
Copy link

I can't explain you why, while i don't have deep understanding of
GSS algorithms. But i guess it has connection with how things are calculated,
because its still math with order.

GSS obviously don't know where is #container[top],
so if you add : #container[top] == ::window[top],
it will behave equally.

@qm3ster
Copy link

qm3ster commented May 15, 2016

You'll notice that in the first case the #containter has top: -64px
This is caused by neither of the two elements having any vertical constraints to the reference frame. They are underqualified.
The order of operations indeed changes because it doesn't affect performance, considering you could write constructs like .a[top]-.b[top]=.b[bottom]-.c[top].
Finally, if you look even closer, you will see that the solution is actually correct, since the #container is not only presumably but physically at top: -64px, relative to the window, and #logo is top: 64px from it. Setting #logo[top] to be 0 in developer tools clearly indicates the effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants