1.0.0 • Published 3 years ago
@andres-oshiro/ng-lazy-load-image v1.0.0
Demo
Visit the demo page.
Source code
Github repository.
Installation
npm i @andres-oshiro/ng-lazy-load-image
Usage
<img anLazyLoadImage [imgSrc]="${imgUrl}" />
Options
You can pass as option a root element, root margin and threshold.
sample-list.component.html
<div id="root">
...
<img anLazyLoadImage [lazyLoadOptions]="OPTIONS" [imgSrc]="${imgUrl}" />
</div>
sample-list-component.ts
@Component(...)
export class SampleListComponent {
public readonly OPTIONS: LazyLoadOptions = {
onErrorImgSrc: this.errorImageSrc,
root: this.document.querySelector('#root'),
rootMargin: '0px 0px 0px 0px',
threshold: 0.5
};
}
Old Browser
anLazyLoadImage uses IntersectionObserver internally. To support old browsers you will need to install IntersectionObserver polyfill.
npm install intersection-observer
After install, import it at Angular's polyfill.ts
/**********************************************************
* APPLICATION IMPORTS
*/
import 'intersection-observer';
*
If your project only needs to support the latest version of Chrome, you can use the browser's native lazy loading.
1.0.0
3 years ago
0.0.0-rc.19
3 years ago
0.0.0-rc.18
3 years ago
0.0.0-rc.17
3 years ago
0.0.0-rc.16
3 years ago
0.0.0-rc.14
3 years ago
0.0.0-rc.13
3 years ago
0.0.0-rc.12
3 years ago
0.0.0-rc.11
3 years ago
0.0.0-rc.15
3 years ago
0.0.0-rc.10
3 years ago
0.0.0-rc.9
3 years ago
0.0.0-rc.8
3 years ago
0.0.0-rc.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.2
3 years ago