Fade

fade

Fade a HTML element using CSS transitions.

Yes, you read it right, this module helps you to fade a HTML element. "Do one thing and do it right!", looks like the moto behind this module, that lets us to fade.in, fade.out and fade an element to a specifie opacity, which also takes a callback as one of it's params and execute it after animation ends and works across browsers with vendor prefixes.

Install it: npm install --save fade # browserify it!

Usage:

1
2
3
4
5
6
7
8
9
10
var fade = require('fade');

var el = document.querySelector('#el');

fade.out(el); // fade el out in 1s
fade.in(el, 1500); // fade el in in 1.5s
fade(el, 0.3, 3000); // fade el to opacity 0.3 in 3s 
fade.out(el, function() {
  el.style.display = 'none'; // set display to none after fade out
});

GIF FTW!

fade.gif

Thanks to Julian Gruber for this sweet little module.

Suggest a module

Comments