slightlyoff / cassowary.js

Cassowary/JS, better, faster, future-ready
Other
1.69k stars 107 forks source link

In a StayConstraint, the constant should always be equal to the variable's value. #51

Closed cacaodev closed 10 years ago

cacaodev commented 10 years ago

Added a failing test in tests/Constraint-test.js

slightlyoff commented 10 years ago

Not passing tests, but will merge and investigate.

cacaodev commented 10 years ago

What i am trying to achieve is to change the stay variable value by editing it. This is why in my test, the stay constraint is created with a weaker strength than the edit strength. Maybe 'weak' is not appropriate for a stay but this is the idea.

Then, i'm expecting the constant value (var[value=newValue] = newValue) to follow the variable change. I could not find any solid info about the "normal" behavior for the constant. It just feels right that a stay behaves like a magnet (stick to the new position) than a spring (attracted to the old position).

The test as modified just tests that when the variable value is not changing, the constant neither changes. Which is right but not the behavior/ bug I wanted to expose.