Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions angular-deckgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [

'Deckgrid',
'$templateCache',
'$window',
'$q',

function initialize (Deckgrid, $templateCache) {
function initialize (Deckgrid, $templateCache, $window, $q) {

'use strict';

Expand Down Expand Up @@ -96,7 +98,10 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
*
*/
Descriptor.prototype.$$link = function $$link (scope, elem, attrs, nullController, transclude) {
var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.$$templateKeyIndex);
var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.$$templateKeyIndex),
self = this,
styleReady = $q.defer(),
domWatch;

scope.$on('$destroy', this.$$destroy.bind(this));

Expand Down Expand Up @@ -135,7 +140,19 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [

scope.mother = scope.$parent;

this.$$deckgrid = Deckgrid.create(scope, elem[0]);
// Wait for style to be ready on deckgrid element
domWatch = scope.$watch(function() {
return $window.getComputedStyle(elem[0], ':before').content;
}, function(content) {
if (content !== '') {
styleReady.resolve();
// Clear the watcher once element is initialized
domWatch();
}
});
styleReady.promise.then(function() {
self.$$deckgrid = Deckgrid.create(scope, elem[0]);
});
};

return {
Expand Down
2 changes: 1 addition & 1 deletion angular-deckgrid.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions src/descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [

'Deckgrid',
'$templateCache',
'$window',
'$q',

function initialize (Deckgrid, $templateCache) {
function initialize (Deckgrid, $templateCache, $window, $q) {

'use strict';

Expand Down Expand Up @@ -69,7 +71,10 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [
*
*/
Descriptor.prototype.$$link = function $$link (scope, elem, attrs, nullController, transclude) {
var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.$$templateKeyIndex);
var templateKey = 'deckgrid/innerHtmlTemplate' + (++this.$$templateKeyIndex),
self = this,
styleReady = $q.defer(),
domWatch;

scope.$on('$destroy', this.$$destroy.bind(this));

Expand Down Expand Up @@ -108,7 +113,19 @@ angular.module('akoenig.deckgrid').factory('DeckgridDescriptor', [

scope.mother = scope.$parent;

this.$$deckgrid = Deckgrid.create(scope, elem[0]);
// Wait for style to be ready on deckgrid element
domWatch = scope.$watch(function() {
return $window.getComputedStyle(elem[0], ':before').content;
}, function(content) {
if (content !== '') {
styleReady.resolve();
// Clear the watcher once element is initialized
domWatch();
}
});
styleReady.promise.then(function() {
self.$$deckgrid = Deckgrid.create(scope, elem[0]);
});
};

return {
Expand Down