KO
|
EN
gitlite โ search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
ng-lazy-load
โ 12
Open GitHub โ
Lazy loading images with Angular.
Download README (.md)
Explore Similar Repositories
Billboard
:
๐
password_manager
:
Military-Grade Password Manager
ACS-VRP
:
This is a project using Ant Colony System to vehicle routing problem.
elastic-grok-script-plugin
:
Elastic-Grok-Script-Plugin is a provider of Grok ElasticSearch plug-in
heroku-dnsimple-cert
:
Update SSL certificate on Heroku from DNSimple
// repository documentation
Was this content helpful?
โ 0
(0 ratings)
Select Rating:
โ
โ
โ
โ
โ
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
ng-lazy-load
?
Download (.md)
# Ng Lazy Load [](https://badge.fury.io/js/%40greg-md%2Fng-lazy-load) [](https://travis-ci.org/greg-md/ng-lazy-load) Lazy loading images with Angular. # Table of Contents: * [Installation](#installation) * [How It Works](#how-it-works) * [Directive Attributes](#directive-attributes) * [License](#license) * [Huuuge Quote](#huuuge-quote) ## Installation To install this library, run: ```bash $ npm install @greg-md/ng-lazy-load --save ``` # How It Works ### Setting up in a module ```typescript import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; // 1. Import lazy loading module; import { LazyLoadModule } from '@greg-md/ng-lazy-load'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule, // 2. Register lazy loading module. LazyLoadModule, ], declarations: [ AppComponent, ], bootstrap: [AppComponent] }) export class AppModule { } ``` ### Using in templates ```typescript import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` <img src="loading.jpg" lazy-load="lazy-image.jpg" /> `, }) export class AppComponent { } ``` # Directive Attributes ## threshold By default images are loaded when they appear on the screen. If you want images to load earlier, use threshold parameter. Setting threshold to 200 causes image to load 200 pixels before it appears on viewport. _Example:_ ```html <img src="loading.jpg" lazy-load="lazy-image.jpg" threshold="200" /> ``` ## container You can also use directive for images inside scrolling container, such as div with scrollbar. Just pass the container element. _Example:_ ```html <div #container> <img src="loading.jpg" lazy-load="lazy-image.jpg" threshold="200" [container]="container" /> </div> ``` ## bg-src Set default image in background and lazy load image directly in the `src` attribute. > Useful with non-effective image URLs. This will avoid to load lazy image twice. _Example:_ ```html <img bg-src="loading.jpg" lazy-load="lazy-image.jpg" width="200" height="200" /> ``` # License MIT ยฉ [Grigorii Duca](http://greg.md) # Huuuge Quote 