GithubHelp home page GithubHelp logo

alexhoo / angular-image-preloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orafaelfragoso/angular-image-preloader

0.0 2.0 0.0 449 KB

Asynchronous Image Preloader Directive for Angular 1.X.

License: MIT License

JavaScript 100.00%

angular-image-preloader's Introduction

Angular Image Preloader Build Status npm version Bower version

Asynchronous Image Preloader Directive for Angular 1.X.

Why?

Images load syncronously. The only problem is that they are render blocking and browsers only let you do limited concurrent requests to specific domains (See this). I made this AngularJS directive to get around this issue on projects that servers large datasets of images from different domains, like the project this was built for.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See usage for notes on how to use the project on a live project.

Prerequisites

AngularJS 1.X

Installing

Install it with NPM, Bower or Yarn:

npm install --save angular-image-preloader
bower install --save angular-image-preloader
yarn add angular-image-preloader

After installed and imported to the project, you should be able to load the module like so:

angular.module('your-module', ['angular-image-preloader']);

Using

Asynchronously loading images with img:

<img preload-image ng-src="your-image.jpg"
     default-image="a-default-image.jpg"
     fallback-image="a-fallback-image.jpg" />

Asynchronously loading background images with CSS:

<div preload-bg-image="your-image.jpg"
     default-image="a-default-image.jpg"
     fallback-image="a-fallback-image.jpg"></div>

Executing a callback after image loads:

<div on-img-load="callback()"
     preload-bg-image="your-image.jpg"
     default-image="a-default-image.jpg"
     fallback-image="a-fallback-image.jpg"></div>

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

TODO

  • Tests

License

This project is licensed under the MIT License - see the LICENSE file for details

angular-image-preloader's People

Contributors

orafaelfragoso avatar alexhoo avatar

Watchers

James Cloos avatar  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.