Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save realtomaszkula/a51266bd3c4bec5316dda30d325408ff to your computer and use it in GitHub Desktop.
Save realtomaszkula/a51266bd3c4bec5316dda30d325408ff to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-progressive-image',
template: `<ng-content></ng-content>`,
})
export class ProgressiveImageComponent implements AfterContentChecked {
@ContentChild(ProgressiveImageDirective) image: ProgressiveImageDirective;
@ContentChild(ProgressiveImageFallbackDirective)
fallback: ProgressiveImageFallbackDirective;
@ContentChild(ProgressiveImagePlaceholderDirective)
placeholder: ProgressiveImagePlaceholderDirective;
@HostBinding('style.height.px')
@Input()
height: number;
@HostBinding('style.width.px')
@Input()
width: number;
ngAfterContentChecked() {
this.image.height = this.height;
this.image.width = this.width;
this.fallback.height = this.height;
this.fallback.width = this.width;
this.placeholder.height = this.height;
this.placeholder.width = this.width;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment