Skip to content

Commit

Permalink
fix: Img source srcset issue on window resize in lazyLoad mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-shaposhnik committed Aug 6, 2020
1 parent 8db594e commit c712166
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion projects/lib/src/lib/img/img.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ export class ImgComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy
ngOnInit() {
this.resizeObservable$ = fromEvent(window, 'resize').pipe(debounceTime(500));
this.resizeSubscription$ = this.resizeObservable$.subscribe(() => {
if (this.isAdaptive || this.windowInnerWidth < window.innerWidth) {
/**
* Don't need to re-process image on window resize in isLazyLoadingMode, because it's provide an issue
* in <source [attr.lazyLoad] />. After image re-processed source elements lose srcset attritute and
* as the result user see not correct image.
*/
if (!this.isLazyLoadingMode && (this.isAdaptive || this.windowInnerWidth < window.innerWidth)) {
this.processImage();
}
this.windowInnerWidth = window.innerWidth;
Expand Down

0 comments on commit c712166

Please sign in to comment.