Skip to content

Releases: tjoskar/ng-lazyload-image

v9.1.3

23 May 05:02
Compare
Choose a tag to compare

Fix

  • Include prerender.io to the bot list. See #545. Thanks @varrocs

v9.1.2

15 Jan 12:39
Compare
Choose a tag to compare

Feature

  • Remove main from package.json. Fixes #539

v9.1.1

06 Jan 09:24
Compare
Choose a tag to compare

Feature

  • Support Angular 13

v9.1.0

14 Nov 09:24
Compare
Choose a tag to compare

Feature

  • Support Angular 11

v9.0.2

14 Nov 09:24
Compare
Choose a tag to compare

Bug fix

  • Pass attributes as argument to skipLazyLoading. See #483 Thanks to kp42 馃帀

Feature

  • Export LazyLoadImageDirective. See #486

v9.0.1

27 Aug 17:49
Compare
Choose a tag to compare

Bugfix

Fixing ScrollHooks for Angular 8. See #476

v9.0.0

25 Jul 19:17
Compare
Choose a tag to compare

Bug fix

  • In some cases users are facing the error: "useClass cannot be undefined". I don't know why but it seams to have something to do with Ivy. See: #463 The solution to this issue was to remove forRoot and instead export a InjectionToken that the user can use to inject a custom Hook set. See Braking change below:

Braking change

Before:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes } from 'ng-lazyload-image';
import { AppComponent } from './app.component';

class LazyLoadImageHooks extends IntersectionObserverHooks {
  async loadImage({ imagePath }: Attributes): Promise<string> {
    return await fetch(imagePath, {
      headers: {
        Authorization: 'Bearer ...',
      },
    })
      .then((res) => res.blob())
      .then((blob) => URL.createObjectURL(blob));
  }
}

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, LazyLoadImageModule.forRoot(LazyLoadImageHooks)],
  bootstrap: [AppComponent],
})
export class MyAppModule {}

After:

import { NgModule, Injectable } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
import { AppComponent } from './app.component';

export class LazyLoadImageHooks extends IntersectionObserverHooks {
  async loadImage({ imagePath }: Attributes): Promise<string> {
    return await fetch(imagePath, {
      headers: {
        Authorization: 'Bearer ...',
      },
    })
      .then((res) => res.blob())
      .then((blob) => URL.createObjectURL(blob));
  }
}

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, LazyLoadImageModule],
  providers: [{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks }],
  bootstrap: [AppComponent],
})
export class MyAppModule {}

When using dependencies:

Before:

import { NgModule, Injectable } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes } from 'ng-lazyload-image';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { AppComponent } from './app.component';

export class LazyLoadImageHooks extends IntersectionObserverHooks {
  private http: HttpClient;

  constructor(http: HttpClient) {
    super();
    this.http = http;
  }

  loadImage({ imagePath }: Attributes): Observable<string> {
    // Load the image through `HttpClient` and cancel the request if the user change page or the image gets removed
    return this.http.get(imagePath, { responseType: 'blob' }).pipe(map(blob => URL.createObjectURL(blob)));
  }
}

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, HttpClientModule, LazyLoadImageModule.forRoot(IntersectionObserverHooks, [HttpClient])],
  providers: [{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks }],
  bootstrap: [AppComponent],
})
export class MyAppModule {}

After:

import { NgModule, Injectable } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { LazyLoadImageModule, IntersectionObserverHooks, Attributes, LAZYLOAD_IMAGE_HOOKS } from 'ng-lazyload-image';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { AppComponent } from './app.component';

@Injectable()
export class LazyLoadImageHooks extends IntersectionObserverHooks {
  private http: HttpClient;

  constructor(http: HttpClient) {
    super();
    this.http = http;
  }

  loadImage({ imagePath }: Attributes): Observable<string> {
    // Load the image through `HttpClient` and cancel the request if the user change page or the image gets removed
    return this.http.get(imagePath, { responseType: 'blob' }).pipe(map(blob => URL.createObjectURL(blob)));
  }
}

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, HttpClientModule, LazyLoadImageModule],
  providers: [{ provide: LAZYLOAD_IMAGE_HOOKS, useClass: LazyLoadImageHooks }],
  bootstrap: [AppComponent],
})
export class MyAppModule {}

v8.0.1

09 Jun 10:33
Compare
Choose a tag to compare
8.0.1

v4.0.0

19 May 17:59
Compare
Choose a tag to compare
v4.0.0

v3.0.0

25 Mar 13:46
Compare
Choose a tag to compare
v3.0.0