mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 08:20:13 +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) {
|
constructor(private _baConfig:BaThemeConfigProvider, private _baCardBlurHelper:BaCardBlurHelper, private _el:ElementRef) {
|
||||||
if (this._isEnabled()) {
|
if (this._isEnabled()) {
|
||||||
|
this._baCardBlurHelper.init();
|
||||||
this._getBodyImageSizesOnBgLoad();
|
this._getBodyImageSizesOnBgLoad();
|
||||||
this._recalculateCardStylesOnBgLoad();
|
this._recalculateCardStylesOnBgLoad();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,29 +7,12 @@ export class BaCardBlurHelper {
|
||||||
private image:HTMLImageElement;
|
private image:HTMLImageElement;
|
||||||
private imageLoadSubject:Subject<void>;
|
private imageLoadSubject:Subject<void>;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
|
public init() {
|
||||||
this._genBgImage();
|
this._genBgImage();
|
||||||
this._genImageLoadSubject();
|
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> {
|
public bodyBgLoad():Subject<void> {
|
||||||
return this.imageLoadSubject;
|
return this.imageLoadSubject;
|
||||||
}
|
}
|
||||||
|
|
@ -51,4 +34,22 @@ export class BaCardBlurHelper {
|
||||||
}
|
}
|
||||||
return { width: finalWidth, height: finalHeight, positionX: (elemW - finalWidth)/2, positionY: (elemH - finalHeight)/2};
|
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