Skip to content

Commit

Permalink
resolve errors wheh using lazyload and ssr (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
strausr authored Apr 25, 2021
1 parent f0067fe commit 618f62a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AfterViewInit, Directive, ElementRef} from '@angular/core';

import { isBrowser } from './cloudinary.service';

@Directive({
selector: 'cl-image[loading=lazy]'
Expand All @@ -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() {
Expand Down

0 comments on commit 618f62a

Please sign in to comment.