mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 23:40:14 +01:00
bacard directive fix
This commit is contained in:
parent
5fa1b335c6
commit
cd6290219f
2 changed files with 21 additions and 19 deletions
|
|
@ -16,6 +16,7 @@ export class BaCardBlur {
|
|||
|
||||
constructor(private _baConfig:BaThemeConfigProvider, private _baCardBlurHelper:BaCardBlurHelper, private _el:ElementRef) {
|
||||
if (this._isEnabled()) {
|
||||
this._baCardBlurHelper.init();
|
||||
this._getBodyImageSizesOnBgLoad();
|
||||
this._recalculateCardStylesOnBgLoad();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,29 +7,12 @@ export class BaCardBlurHelper {
|
|||
private image:HTMLImageElement;
|
||||
private imageLoadSubject:Subject<void>;
|
||||
|
||||
constructor() {
|
||||
|
||||
public init() {
|
||||
this._genBgImage();
|
||||
this._genImageLoadSubject();
|
||||
}
|
||||
|
||||
private _genBgImage():void {
|
||||
this.image = new Image();
|
||||
let computedStyle = getComputedStyle(document.body, ':before');
|
||||
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
|
||||
}
|
||||
|
||||
private _genImageLoadSubject():void {
|
||||
this.imageLoadSubject = new Subject<void>();
|
||||
this.image.onerror = () => {
|
||||
this.imageLoadSubject.error();
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
this.image.onload = () => {
|
||||
this.imageLoadSubject.next(null);
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
}
|
||||
|
||||
public bodyBgLoad():Subject<void> {
|
||||
return this.imageLoadSubject;
|
||||
}
|
||||
|
|
@ -51,4 +34,22 @@ export class BaCardBlurHelper {
|
|||
}
|
||||
return { width: finalWidth, height: finalHeight, positionX: (elemW - finalWidth)/2, positionY: (elemH - finalHeight)/2};
|
||||
}
|
||||
|
||||
private _genBgImage():void {
|
||||
this.image = new Image();
|
||||
let computedStyle = getComputedStyle(document.body, ':before');
|
||||
this.image.src = computedStyle.backgroundImage.replace(/url\((['"])?(.*?)\1\)/gi, '$2');
|
||||
}
|
||||
|
||||
private _genImageLoadSubject():void {
|
||||
this.imageLoadSubject = new Subject<void>();
|
||||
this.image.onerror = () => {
|
||||
this.imageLoadSubject.error();
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
this.image.onload = () => {
|
||||
this.imageLoadSubject.next(null);
|
||||
this.imageLoadSubject.complete();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue