Skip to content

Commit 618f62a

Browse files
authored
resolve errors wheh using lazyload and ssr (#306)
1 parent f0067fe commit 618f62a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

projects/angular-cld/src/lib/cloudinary-lazy-load.directive.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AfterViewInit, Directive, ElementRef} from '@angular/core';
2-
2+
import { isBrowser } from './cloudinary.service';
33

44
@Directive({
55
selector: 'cl-image[loading=lazy]'
@@ -9,11 +9,13 @@ export class LazyLoadDirective implements AfterViewInit {
99
constructor(private el: ElementRef) {}
1010

1111
ngAfterViewInit() {
12+
if (isBrowser()) {
1213
if (!this.isNativeLazyLoadSupported() && this.isLazyLoadSupported()) {
1314
this.lazyLoad();
1415
} else {
1516
this.loadImage();
1617
}
18+
}
1719
}
1820

1921
loadImage() {

0 commit comments

Comments
 (0)