bgfade

JavaScript Library to switch display of DOM elements with fade.

Link

Demo

Normal

  • 1
  • 2
  • 3
import bgfade from 'bgfade';

window.addEventListener('load', () => {
 bgfade('normal');
});

Control

  • 1
  • 2
  • 3
import bgfade from 'bgfade';

window.addEventListener('load', () => {
 const bg = bgfade('control');

 // click event
 document.getElementById('start').addEventListener('click', () => {
   bg.start();
 });
 document.getElementById('stop').addEventListener('click', () => {
   bg.stop();
 });
});

Customize

import bgfade from 'bgfade';

window.addEventListener('load', () => {
 bgfade('customize', {
   speed: 4,
   duration: 5
 });
});