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

Commit adb2281

Browse files
update(Layout): add ngCloak intercept
Delay the un-cloaking while the Layout injections finish processing. * update docs to use 'Layout' instead of 'Grid'
1 parent f73e503 commit adb2281

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

docs/app/js/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind
252252
id: 'layoutContainers',
253253
url: 'layout/container'
254254
},{
255-
name: 'Grid System',
255+
name: 'Layout System',
256256
id: 'layoutGrid',
257257
url: 'layout/grid'
258258
},{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
</docs-demo>
121121

122122
<p>
123-
See the <a href="layout/grid">Grid System</a> page for a basic explanation
123+
See the <a href="layout/grid">Layout System</a> page for a basic explanation
124124
of flex and offset attributes.
125125
</p>
126126

src/core/services/layout/layout.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
var config = {
1616
/**
1717
* Enable directive attribute-to-class conversions
18+
* Developers can use `<body md-layout-css />` to quickly
19+
* disable the Layout directivees and prohibit the injection of Layout classnames
1820
*/
1921
enabled: true,
2022

@@ -167,7 +169,9 @@
167169
.directive('hideLtMd', warnAttrNotSupported('hide-lt-md'))
168170
.directive('hideLtLg', warnAttrNotSupported('hide-lt-lg'))
169171
.directive('showLtMd', warnAttrNotSupported('show-lt-md'))
170-
.directive('showLtLg', warnAttrNotSupported('show-lt-lg'));
172+
.directive('showLtLg', warnAttrNotSupported('show-lt-lg'))
173+
174+
.directive('ngCloak', buildCloakInterceptor('ng-cloak'));
171175

172176
/**
173177
* Special directive that will disable ALL Layout conversions of layout
@@ -209,6 +213,31 @@
209213
//
210214
// *********************************************************************************
211215

216+
/**
217+
* Tail-hook ngCloak to delay the uncloaking while Layout transformers
218+
* finish processing. Eliminates flicker with Material.Layoouts
219+
*/
220+
function buildCloakInterceptor(className) {
221+
return [ '$timeout', function($timeout){
222+
return {
223+
restrict : 'A',
224+
priority : -10, // run after normal ng-cloak
225+
compile : function( element ) {
226+
if (!config.enabled) return angular.noop;
227+
228+
// Re-add the cloak
229+
element.addClass(className);
230+
231+
return function( scope, element ) {
232+
// Wait while layout injectors configure, then uncload
233+
$timeout( function(){
234+
element.removeClass(className);
235+
}, 10, false);
236+
};
237+
}
238+
};
239+
}];
240+
}
212241

213242
/**
214243
* Creates a directive registration function where a possible dynamic attribute

0 commit comments

Comments
 (0)