Code Monkey home page Code Monkey logo

ionic-image-lazy-load's Introduction

ionic-image-lazy-load

Demo

http://codepen.io/mvidailhet/pen/yNOGzY http://codepen.io/pavei/pen/oFpCy

Quick Start

Install using bower

bower install ion-image-lazy-load --save

or

Download the file JS ionic-image-lazy-load.js, save on your project and load it on your index.html.

<script src="path/to/ionic-image-lazy-load.js"></script>

Load into your module:

angular.module('yourapp',
              ['ionic', 'ionicLazyLoad'])

Set the lazy-scroll directive on your <ion-content> tag, that will listen to the scroll event:

<ion-content lazy-scroll>

And set the image-lazy-src directive on the image attribute instead of src:

 <img image-lazy-src="{{item.thumbnail}}">

You can also use it as a background-image for an element by setting the image-lazy-background-image paramameter to true:

<div image-lazy-src="{{item.thumbnail}}" image-lazy-background-image="true"></div>

You can also set an option to auto call $ionicScrollDelegate.resize() when the image load (default value is false):

 <img image-lazy-src="{{item.thumbnail}}" lazy-scroll-resize="true">

To show a ionic spinner while the image is loading, just specify a ionic spinner type (list is here: http://ionicframework.com/docs/api/directive/ionSpinner/):

 <img image-lazy-src="{{item.thumbnail}}" image-lazy-loader="lines">

Note: the styling of the loader position is up to you. The directive adds this html:

<div class="image-loader-container">
    <ion-spinner class="image-loader" icon="#spinnerStyle#"></ion-spinner>
</div>

You can set a distance from the bottom or right side of the screen where the image will start loading. This will allow to start loading the image 100px below the bottom of the screen:

 <img image-lazy-src="{{item.thumbnail}}" image-lazy-distance-from-bottom-to-load="100">

This will allow to start loading the image 100px before the right side of the screen:

 <img image-lazy-src="{{item.thumbnail}}" image-lazy-distance-from-right-to-load="100">

ionic-image-lazy-load's People

Contributors

pavei avatar rossmartin avatar cantecim avatar danilopavei avatar davidepastore avatar mvidailhet avatar renekorss avatar ssokurenko avatar kristiyandobrev avatar wicky26 avatar

Watchers

James Cloos avatar abhay  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.