mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 07:50:12 +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 {Component, ViewEncapsulation, Input} from 'angular2/core';
|
||||||
|
|
||||||
|
import {BaCardBlur} from './baCardBlur.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ba-card',
|
selector: 'ba-card',
|
||||||
styles: [require('./baCard.scss')],
|
styles: [require('./baCard.scss')],
|
||||||
|
directives: [BaCardBlur],
|
||||||
template: require('./baCard.html'),
|
template: require('./baCard.html'),
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<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">
|
<div *ngIf="title" class="card-header clearfix">
|
||||||
<h3 class="card-title">{{title}}</h3>
|
<h3 class="card-title">{{title}}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@ export class BaCardBlur {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getBodyImageSizesOnBgLoad():void {
|
private _getBodyImageSizesOnBgLoad():void {
|
||||||
this._baCardBlurHelper.bodyBgLoad().then(function() {
|
this._baCardBlurHelper.bodyBgLoad().subscribe(() => {
|
||||||
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
this._bodyBgSize = this._baCardBlurHelper.getBodyBgImageSizes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _recalculateCardStylesOnBgLoad():void {
|
private _recalculateCardStylesOnBgLoad():void {
|
||||||
this._baCardBlurHelper.bodyBgLoad().then(() => {
|
this._baCardBlurHelper.bodyBgLoad().subscribe((event) => {
|
||||||
setTimeout(this._recalculateCardStyle);
|
setTimeout(this._recalculateCardStyle.bind(this));
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private _recalculateCardStyle():void {
|
private _recalculateCardStyle():void {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import {Injectable} from 'angular2/core'
|
import {Injectable} from 'angular2/core'
|
||||||
|
|
||||||
import {BgMetrics} from './bgMetrics';
|
import {BgMetrics} from './bgMetrics';
|
||||||
|
import {Subject} from 'rxjs/Subject';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BaCardBlurHelper {
|
export class BaCardBlurHelper {
|
||||||
private image:HTMLImageElement;
|
private image:HTMLImageElement;
|
||||||
private imageLoadDeferred = Promise.defer(); //TODO: Promises or Observables refactor
|
private imageLoadSubject:Subject<void>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._genBgImage();
|
this._genBgImage();
|
||||||
this._setImageLoadResolves()
|
this._genImageLoadSubject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _genBgImage():void {
|
private _genBgImage():void {
|
||||||
|
|
@ -18,17 +18,20 @@ export class BaCardBlurHelper {
|
||||||
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
|
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.image.onerror = () => {
|
||||||
this.imageLoadDeferred.reject();
|
this.imageLoadSubject.error();
|
||||||
|
this.imageLoadSubject.complete();
|
||||||
};
|
};
|
||||||
this.image.onload = () => {
|
this.image.onload = () => {
|
||||||
this.imageLoadDeferred.resolve();
|
this.imageLoadSubject.next(null);
|
||||||
|
this.imageLoadSubject.complete();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public bodyBgLoad():Promise {
|
public bodyBgLoad():Subject<void> {
|
||||||
return this.imageLoadDeferred.promise;
|
return this.imageLoadSubject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBodyBgImageSizes():BgMetrics {
|
public getBodyBgImageSizes():BgMetrics {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue