From 618f62a1d803913893f49f8034aa4baa7b17b2d0 Mon Sep 17 00:00:00 2001 From: strausr Date: Sun, 25 Apr 2021 15:16:00 +0300 Subject: [PATCH] resolve errors wheh using lazyload and ssr (#306) --- .../angular-cld/src/lib/cloudinary-lazy-load.directive.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/angular-cld/src/lib/cloudinary-lazy-load.directive.ts b/projects/angular-cld/src/lib/cloudinary-lazy-load.directive.ts index 0be8ea51..807a90de 100644 --- a/projects/angular-cld/src/lib/cloudinary-lazy-load.directive.ts +++ b/projects/angular-cld/src/lib/cloudinary-lazy-load.directive.ts @@ -1,5 +1,5 @@ import {AfterViewInit, Directive, ElementRef} from '@angular/core'; - +import { isBrowser } from './cloudinary.service'; @Directive({ selector: 'cl-image[loading=lazy]' @@ -9,11 +9,13 @@ export class LazyLoadDirective implements AfterViewInit { constructor(private el: ElementRef) {} ngAfterViewInit() { + if (isBrowser()) { if (!this.isNativeLazyLoadSupported() && this.isLazyLoadSupported()) { this.lazyLoad(); } else { this.loadImage(); } + } } loadImage() {