Skip to content

Commit

Permalink
fix(fxLayoutGap): add proper gaps for reverse dir
Browse files Browse the repository at this point in the history
  • Loading branch information
CaerusKaru authored and ThomasBurleson committed Mar 20, 2018
1 parent 0562fcc commit 3a8041d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/lib/flex/layout-gap/layout-gap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ describe('layout-gap directive', () => {
verifyCorrectMargin('column', 'margin-bottom');
});

it('should apply margin-right for row-reverse layouts', () => {
verifyCorrectMargin('row-reverse', 'margin-right');
it('should apply margin-left for row-reverse layouts', () => {
verifyCorrectMargin('row-reverse', 'margin-left');
});

it('should apply margin-bottom for column-reverse layouts', () => {
verifyCorrectMargin('column-reverse', 'margin-bottom');
it('should apply margin-top for column-reverse layouts', () => {
verifyCorrectMargin('column-reverse', 'margin-top');
});

it('should remove obsolete margin and apply valid margin for layout changes', () => {
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('layout-gap directive', () => {
nodes = queryFor(fixture, 'span');

expectEl(nodes[0]).not.toHaveStyle({'margin-right': '8px'}, styler);
expectEl(nodes[0]).toHaveStyle({'margin-bottom': '8px'}, styler);
expectEl(nodes[0]).toHaveStyle({'margin-top': '8px'}, styler);


// layout = row-reverse, use margin-right
Expand All @@ -250,7 +250,7 @@ describe('layout-gap directive', () => {
nodes = queryFor(fixture, 'span');

expectEl(nodes[0]).not.toHaveStyle({'margin-bottom': '8px'}, styler);
expectEl(nodes[0]).toHaveStyle({'margin-right': '8px'}, styler);
expectEl(nodes[0]).toHaveStyle({'margin-left': '8px'}, styler);
});

it('should recognize hidden elements when applying gaps', () => {
Expand Down
10 changes: 8 additions & 2 deletions src/lib/flex/layout-gap/layout-gap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,17 @@ export class LayoutGapDirective extends BaseFxDirective

switch (this._layout) {
case 'column':
case 'column-reverse':
key = 'margin-bottom';
break;
case 'row' :
case 'column-reverse':
key = 'margin-top';
break;
case 'row':
key = this._directionality.value === 'rtl' ? 'margin-left' : 'margin-right';
break;
case 'row-reverse':
key = this._directionality.value === 'rtl' ? 'margin-right' : 'margin-left';
break;
default :
key = this._directionality.value === 'rtl' ? 'margin-left' : 'margin-right';
break;
Expand Down

0 comments on commit 3a8041d

Please sign in to comment.