Skip to content

Commit ec23f16

Browse files
eitanp461tocker
authored andcommitted
Set common background properties for CloudinaryBackgroundImageDirective
1 parent 8fd2e8c commit ec23f16

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/cloudinary-background-image.directive.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ export class CloudinaryBackgroundImageDirective implements AfterViewInit {
1616
}
1717

1818
ngAfterViewInit() {
19-
const nativeElement = this.el.nativeElement;
20-
const options = this.cloudinary.toCloudinaryAttributes(nativeElement.attributes, this.transformations);
21-
const imageUrl = this.cloudinary.url(this.clBackgroundImage, options);
22-
this.renderer.setStyle(this.el.nativeElement, 'background-image', `url('${imageUrl}')`);
23-
};
19+
const nativeElement = this.el.nativeElement;
20+
const options = this.cloudinary.toCloudinaryAttributes(nativeElement.attributes, this.transformations);
21+
const imageUrl = this.cloudinary.url(this.clBackgroundImage, options);
22+
this.renderer.setStyle(nativeElement, 'background-image', `url('${imageUrl}')`);
23+
this.renderer.setStyle(nativeElement, 'background-repeat', 'no-repeat');
24+
this.renderer.setStyle(nativeElement, 'background-position', 'center');
25+
}
2426
}

0 commit comments

Comments
 (0)