Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 6b1d758

Browse files
ngraefThomasBurleson
authored andcommitted
fix(layout): allow layout-align without cross-axis or main-axis value
* fix parsing issue to allow single value * add demo to test omitting second value fixes #5996. closes #6003.
1 parent 097b799 commit 6b1d758

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

docs/app/js/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ function($scope, $attrs, $location, $rootScope) {
633633
direction: 'row'
634634
};
635635
$scope.layoutAlign = function() {
636-
return $scope.layoutDemo.mainAxis + ' ' + $scope.layoutDemo.crossAxis;
636+
return $scope.layoutDemo.mainAxis +
637+
($scope.layoutDemo.crossAxis ? ' ' + $scope.layoutDemo.crossAxis : '')
637638
};
638639
}])
639640

docs/app/partials/layout-alignment.tmpl.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
<div>
7070
<md-subheader>Alignment in Layout Direction ({{layoutDemo.direction == 'row' ? 'horizontal' : 'vertical'}})</md-subheader>
7171
<md-radio-group ng-model="layoutDemo.mainAxis">
72-
<md-radio-button value="start">start</md-radio-button>
72+
<md-radio-button value="">none</md-radio-button>
73+
<md-radio-button value="start">start (default)</md-radio-button>
7374
<md-radio-button value="center">center</md-radio-button>
7475
<md-radio-button value="end">end</md-radio-button>
7576
<md-radio-button value="space-around">space-around</md-radio-button>
@@ -79,10 +80,11 @@
7980
<div>
8081
<md-subheader>Alignment in Perpendicular Direction ({{layoutDemo.direction == 'column' ? 'horizontal' : 'vertical'}})</md-subheader>
8182
<md-radio-group ng-model="layoutDemo.crossAxis">
83+
<md-radio-button value="none"><em>none</em></md-radio-button>
8284
<md-radio-button value="start">start</md-radio-button>
8385
<md-radio-button value="center">center</md-radio-button>
8486
<md-radio-button value="end">end</md-radio-button>
85-
<md-radio-button value="stretch">stretch</md-radio-button>
87+
<md-radio-button value="stretch">stretch (default)</md-radio-button>
8688
</md-radio-group>
8789
</div>
8890

src/core/services/layout/layout.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Enable directive attribute-to-class conversions
1717
* Developers can use `<body md-layout-css />` to quickly
18-
* disable the Layout directivees and prohibit the injection of Layout classnames
18+
* disable the Layout directives and prohibit the injection of Layout classNames
1919
*/
2020
enabled: true,
2121

@@ -173,15 +173,6 @@
173173
};
174174
}
175175

176-
// *********************************************************************************
177-
//
178-
// These functions create registration functions for ngMaterial Layout attribute directives
179-
// This provides easy translation to switch ngMaterial attribute selectors to
180-
// CLASS selectors and directives; which has huge performance implications
181-
// for IE Browsers
182-
//
183-
// *********************************************************************************
184-
185176
/**
186177
* Tail-hook ngCloak to delay the uncloaking while Layout transformers
187178
* finish processing. Eliminates flicker with Material.Layoouts
@@ -210,6 +201,16 @@
210201
}];
211202
}
212203

204+
205+
// *********************************************************************************
206+
//
207+
// These functions create registration functions for ngMaterial Layout attribute directives
208+
// This provides easy translation to switch ngMaterial attribute selectors to
209+
// CLASS selectors and directives; which has huge performance implications
210+
// for IE Browsers
211+
//
212+
// *********************************************************************************
213+
213214
/**
214215
* Creates a directive registration function where a possible dynamic attribute
215216
* value will be observed/watched.
@@ -427,14 +428,16 @@
427428
return found;
428429
}
429430

430-
function extractAlignAxis(value) {
431+
function extractAlignAxis(config) {
432+
config = (config || "");
433+
431434
var axis = {
432435
main : "start",
433436
cross: "stretch"
434-
};
437+
}, values;
435438

436-
var values = (value || "").toLowerCase().trim().replace(WHITESPACE, "-").split("-");
437-
if ( values.length == 3 ) {
439+
values = (config || "").toLowerCase().trim().replace(WHITESPACE, "-").split("-");
440+
if ( values[0] === "space" ) {
438441
values = [ values[0]+"-"+values[1],values[2] ];
439442
}
440443

0 commit comments

Comments
 (0)