mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 23:40:14 +01:00
baVard work still in progress
This commit is contained in:
parent
cb5739711c
commit
a1a8875225
4 changed files with 20 additions and 14 deletions
|
|
@ -1,8 +1,11 @@
|
|||
import {Component, ViewEncapsulation, Input} from 'angular2/core';
|
||||
|
||||
import {BaCardBlur} from './baCardBlur.directive';
|
||||
|
||||
@Component({
|
||||
selector: 'ba-card',
|
||||
styles: [require('./baCard.scss')],
|
||||
directives: [BaCardBlur],
|
||||
template: require('./baCard.html'),
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<div class="card {{cardType}} {{baCardClass || ''}}" zoom-in ba-panel-blur>
|
||||
<div class="card {{cardType}} card-blur {{baCardClass || ''}}" zoom-in baCardBlur>
|
||||
<div *ngIf="title" class="card-header clearfix">
|
||||
<h3 class="card-title">{{title}}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ export class BaCardBlur {
|
|||
}
|
||||
|
||||
private _getBodyImageSizesOnBgLoad():void {
|
||||
this._baCardBlurHelper.bodyBgLoad().then(function() {
|
||||
this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
|
||||
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
||||
});
|
||||
}
|
||||
|
||||
private _recalculateCardStylesOnBgLoad():void {
|
||||
this._baCardBlurHelper.bodyBgLoad().then(() => {
|
||||
setTimeout(this._recalculateCardStyle);
|
||||
});
|
||||
this._baCardBlurHelper.bodyBgLoad().subscribe((event) => {
|
||||
setTimeout(this._recalculateCardStyle.bind(this));
|
||||
})
|
||||
}
|
||||
|
||||
private _recalculateCardStyle():void {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import {Injectable} from 'angular2/core'
|
||||
|
||||
import {BgMetrics} from './bgMetrics';
|
||||
import {Subject} from 'rxjs/Subject';
|
||||
|
||||
@Injectable()
|
||||
export class BaCardBlurHelper {
|
||||
private image:HTMLImageElement;
|
||||
private imageLoadDeferred = Promise.defer(); //TODO: Promises or Observables refactor
|
||||
private imageLoadSubject:Subject<void>;
|
||||
|
||||
constructor() {
|
||||
this._genBgImage();
|
||||
this._setImageLoadResolves()
|
||||
this._genImageLoadSubject();
|
||||
}
|
||||
|
||||
private _genBgImage():void {
|
||||
|
|
@ -18,17 +18,20 @@ export class BaCardBlurHelper {
|
|||
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
|
||||
}
|
||||
|
||||
private _setImageLoadResolves():void {
|
||||
private _genImageLoadSubject():void {
|
||||
this.imageLoadSubject = new Subject<void>();
|
||||
this.image.onerror = () => {
|
||||
this.imageLoadDeferred.reject();
|
||||
this.imageLoadSubject.error();
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
this.image.onload = () => {
|
||||
this.imageLoadDeferred.resolve();
|
||||
this.imageLoadSubject.next(null);
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
}
|
||||
|
||||
public bodyBgLoad():Promise {
|
||||
return this.imageLoadDeferred.promise;
|
||||
public bodyBgLoad():Subject<void> {
|
||||
return this.imageLoadSubject;
|
||||
}
|
||||
|
||||
public getBodyBgImageSizes():BgMetrics {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue