• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AngularJS Module to make images appear with transition as they load.

ng-image-appear icon

ng-image-appear npm version NPM Downloads Latest Stable Version Patreon donate button

AngularJS Module to make images appear with transition as they load.

Wraps the img tag within a wrapper and adds a gif loader in between. No more ugly-looking progressively loading images!

http://arunmichaeldsouza.github.io/ng-image-appear/

Demo on CodePen

ng-image-appear

This project has also been ported to ReactJS - react-image-appear.


Installation

CDN

Use ng-image-appear directly from jsdelivr CDN

https://cdn.jsdelivr.net/npm/[email protected]/dist/ng-image-appear.min.js

via bower

You can install the package using bower. Make sure you have bower installed, then run :

bower install ng-image-appear

via npm

npm install ng-image-appear

Or, download the latest version and include ng-image-appear.min.js to your project.

Add ngImageAppear as a dependency in your angular app module.


Usage

Include the directive with an img tag in your HTML file with any of the available options.

Include the src and the ng-image-appear directive as an attribute.

Example -

var myApp = angular.module('myApp', ['ngImageAppear']);

myApp.controller('appCtrl', ['$scope', function($scope) {
				
}]);
<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear 
	responsive
	transition-duration="1s"
	animation="fillIn"
	animation-duration="1s"
	easing="ease-out"
/> 

Options

transition-duration

This parameter specifies the transition duration for the image to appear. Default value is 700ms.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	transition-duration="4s"
/> 

bg-color

Adds a background color to the image wrapper element.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	bg-color="#50a4e2"
/> 

bg-color


no-loader

If this option is specified, then no gif loader is shown in the image wrapper element.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	no-loader
/> 

no-loader


responsive

Use this option to make the image wrapper responsive. In that case the width of the wrapper is calculated in %, otherwise it is calculated in px.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	responsive
/> 

responsive


placeholder

Adds a default placeholder in the image wrapper background.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	placeholder
/> 

placeholder

You can override the default placeholder background and add your own by passing an image link to this option.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	placeholder="http://getuikit.com/docs/images/placeholder_600x400.svg"
/> 

placeholder-custom


placeholder-class

Use this option to add a CSS class to the placeholder background.

Example -

<style>
	.placeholder-css {
		background-size: contain;
	}
</style>

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	placeholder
	placeholder-class="placeholder-css"
/> 

placeholder-style

Add CSS styles to the placeholder background using this option.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	placeholder
	placeholder-style="background-size: contain;"
/> 

loader-img

Add a custom gif loader in the image wrapper. Default width and height of the loader is 40px. The image must be a gif.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	loader-img="https://cache.dominos.com/nolo/ca/en/010048/assets/build/images/img/spinner.gif"
/> 

loader-img


loader-class

Use this option to add a CSS class to the loader element.

Example -

<style>
	.loader-css {
		width: 60px; 
		height: 60px; 
		left: calc((100% - 60px) / 2); 
		top: calc((100% - 60px) / 2);
	}
</style>

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	loader-class="loader-css"
/> 

loader-style

Add CSS styles to the loader element using this option.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	loader-styles="width: 60px; height: 60px; left: calc((100% - 60px) / 2); top: calc((100% - 60px) / 2);"
/> 

animation

Add a CSS3 powered animation to the image as it appears. Default animation is fadeIn.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	animation="bounceIn"
/> 

animation

ng-image-appear has the following built-in CSS3 animations -

fadeIn (default)
fadeInUp
fadeInRight
fadeInDown
fadeInLeft
bounceIn
bounceInUp
bounceInRight
bounceInDown
bounceInLeft
flipInX
flipInY
zoomIn
blurIn
blurInUp
blurInRight
blurInDown
blurInLeft
fillIn

animation-duration

This parameter specifies the animation duration for the image to appear. Default value is 700ms.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	animation="fillIn"
	animation-duration="2s"
/> 

easing

Specifies the timing-function for the CSS3 powered transition/animation. Default value is ease-in-out.

Example -

<img 
	src="https://newevolutiondesigns.com/images/freebies/tropical-beach-background-8.jpg" 
	ng-image-appear
	animation="bounceIn"
	easing="ease-out"
/> 

Contributors


Arun Michael Dsouza


Travis Vignon


Lukas Drgon


Support

If you'd like to help support the development of the project, please consider backing me on Patreon -


License

MIT Licensed

Copyright (c) 2016 Arun Michael Dsouza ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

tensorflow-image-detection

A generic image detection program that uses Google's Machine Learning library, Tensorflow and a pre-trained Deep Learning Convolutional Neural Network model called Inception.
Python
330
star
2

react-image-appear

ReactJS component to make images appear with transition as they load.
JavaScript
281
star
3

CSS-Mint

Lightweight and simple to use UI Kit. Fully responsive, just 3KB gzipped.
CSS
212
star
4

joypad.js

JavaScript library that lets you connect and use various gaming controllers with browsers that support the Gamepad API. Less than 5KB in size with zero dependencies and support for button press, axis movement events and vibration play effect.
JavaScript
152
star
5

ng-youtube-embed

AngularJS module to embed Youtube videos with support for Youtube player parameters and JavaScript API for iframe embeds. Superlight (less than 5KB) and easy to use! Supports Youtube video URLs and IDs. No 3rd party JS dependencies.
JavaScript
143
star
6

picla

jQuery plugin that converts Alt-texts into simple image labels
JavaScript
95
star
7

pineapple-sass

A must-have Sass mixin library for all your Sassy needs
CSS
46
star
8

bootstrap-football-homepage

A minimal Bootstrap 3 one page Theme for Football lovers
HTML
39
star
9

ng-textarea-enter

Execute a function on pressing the enter key in a textarea.
JavaScript
37
star
10

D_Pad

Drumming App built with Processing 2, for Desktop/Mobile Environments.
Processing
25
star
11

Zeta

Zeta is a command interpreter built purely in C for Windows OS
C
11
star
12

JSConf-belgium-2017-talk

Slides and demos for my JSConf Belgium 2017 talk.
JavaScript
7
star
13

meteor-discussion-board

Discussion Board app built with Meteor js
JavaScript
6
star
14

arunmichaeldsouza.com

My Personal Website
JavaScript
5
star
15

tuneshuffle

Web-based localised music player. Start a server locally, ask your friends to join in, share and stream music together!
JavaScript
5
star
16

JSConf-iceland-2018-talk

Slides for my JSConf Iceland 2018 talk.
3
star
17

node-instagram-app

Simple app built with Node to display popular images from Instagram
CSS
3
star
18

javascript-and-friends-2020-talk

Slides for my JavaScript & Friends Conference 2020 talk.
3
star
19

javascript-30-course

Solutions for the JavaScript 30 Day Challenge by Wes Bos
HTML
3
star
20

viewport-ratio-js

Script to get ratio of visible area of selected elements in the viewport.
JavaScript
2
star
21

simple-node-server

Simplest node server to serve static files using express
JavaScript
2
star
22

react-foundations

Playing around with React JS
JavaScript
1
star
23

javascript-foundations

JS algorithmic practice problems
JavaScript
1
star
24

isomorphic-react

Experimenting with Isomorphic ReactJS
JavaScript
1
star
25

es-foundations

Playing around with ECMAScript - ES6, ES8
JavaScript
1
star