Skip to content

Instantly share code, notes, and snippets.

@mikkoh
Last active December 26, 2015 12:08
Show Gist options
  • Save mikkoh/7148421 to your computer and use it in GitHub Desktop.
Save mikkoh/7148421 to your computer and use it in GitHub Desktop.
//POSSIBLE CONDITIONAL SYNTAX
node1.matchesWidthOf( layout )
.ifWidthGreaterThan( layout, 600 ).widthIsAPercentageOf( layout, 0.5 )
.ifWidthSmallerThan( layout, 200 ).widthIsAPercentageOf( layout, 0.2 );
//OTHER POSSIBLE CONDITIONAL SYNTAX
node1.matchesWidthOf( layout )
.is( layout ).widthGreaterThan( 600 ).widthIsAPercentageOf( layout, 0.5 )
.is( layout ).widthGreaterThan( 200 ).widthIsAPercentageOf( layout, 0.2 );
@bunnybones1
Copy link

I know flexibility comes at a cost of straightforwardness, but what about:

node1.matchesPropOf( layout, "width" )
.is( layout, "width" ).greaterThan( 600 ).isAPercentageOf( layout, "width", 0.5 )
.is( layout, "width" ).smallerThan( 200 ).isAPercentageOf( layout, "width", 0.2 );

That way, you could control "y" by another's "height" and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment