Skip to content

A loading indicator overlay for images (and maybe other things later).

License

Notifications You must be signed in to change notification settings

zachleat/throbber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<throb-ber> Web Component

A web component to add a little baby rainbow gradient overlay until all of the images nested inside have finished loading. Works best with expensive dynamically generated images (like screenshots).

Features

  • Customize minimum delay before the loading indicator is shown.
  • Customize loading indicator bar height.

Installation

You can install via npm (@zachleat/throbber) or download the throbber.js JavaScript file manually.

npm install @zachleat/throbber --save

Add throbber.js to your site’s JavaScript assets.

Usage

<throb-ber>
	<img src="myimage.png" alt="" width="600" height="400">
</throb-ber>

Change minimum delay

The minimum time before the loading indicator is shown. delay is in milliseconds (0.5 seconds shown).

<throb-ber delay="500">
	<img src="myimage.png" alt="" width="600" height="400">
</throb-ber>

Customize appearance

Dark background while the image is loading, loading indicator fills up the component:

<throb-ber style="background-color: #666; --throbber-height: 100%;">
	<img src="myimage.png" alt="" width="600" height="400">
</throb-ber>

Use your own custom gradient:

<throb-ber style="--throbber-image: linear-gradient(to right, white, rebeccapurple); --throbber-opacity: 1">
	<img src="myimage.png" alt="" width="600" height="400">
</throb-ber>

About

A loading indicator overlay for images (and maybe other things later).

Resources

License

Stars

Watchers

Forks