All Projects → jcubic → favloader

jcubic / favloader

Licence: MIT license
Vanilla JavaScript library for loading animation in favicon (favicon loader)

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to favloader

Gifsee.js
A modern, vanilla JavaScript gif previewer and loader.
Stars: ✭ 48 (+140%)
Mutual labels:  loader, gif
Gifloader
An Android Library to load your GIF files
Stars: ✭ 38 (+90%)
Mutual labels:  loader, gif
favicon-canvas-loader
Create and display a circular loading <canvas> animation as a webpage favicon.
Stars: ✭ 83 (+315%)
Mutual labels:  loader, favicon
clappr-plugins
Main plugins for the Clappr project
Stars: ✭ 22 (+10%)
Mutual labels:  timer, favicon
jsx-compress-loader
⚛️JSX optimisation loader to reduce size of React application
Stars: ✭ 40 (+100%)
Mutual labels:  loader
Chronity
⌛ Library for running functions after a delay by creating timers in Unity3D.
Stars: ✭ 40 (+100%)
Mutual labels:  timer
imagemin-gifsicle
Imagemin plugin for Gifsicle
Stars: ✭ 105 (+425%)
Mutual labels:  gif
vkel
Simple Dynamic Vulkan Extension Loader
Stars: ✭ 39 (+95%)
Mutual labels:  loader
UnityGiphy
Library for using the GiphyAPI in Unity to get and play random Gifs as MP4s
Stars: ✭ 35 (+75%)
Mutual labels:  gif
Splitter
A speedrunning timer for macOS
Stars: ✭ 34 (+70%)
Mutual labels:  timer
meditation-timer
🧘 Progressive web application for timing your meditations
Stars: ✭ 23 (+15%)
Mutual labels:  timer
consoleTimer
Simple timer for your terminal
Stars: ✭ 20 (+0%)
Mutual labels:  timer
crunchygif
EZPZ VIDEO TO GIF CREATOR
Stars: ✭ 33 (+65%)
Mutual labels:  gif
Fileloader
A library for managing file downloads on the Android platform
Stars: ✭ 27 (+35%)
Mutual labels:  loader
langx-java
Java tools, helper, common utilities. A replacement of guava, apache-commons, hutool
Stars: ✭ 50 (+150%)
Mutual labels:  timer
movtogif-cli
📺 Convert mov/mp4 to high-quality animated gifs
Stars: ✭ 58 (+190%)
Mutual labels:  gif
loading
Laravel package to add loading indicator to pages while page is loading.
Stars: ✭ 38 (+90%)
Mutual labels:  loader
image-minimizer-webpack-plugin
Webpack loader and plugin to compress images using imagemin
Stars: ✭ 180 (+800%)
Mutual labels:  loader
sorting-visualization
🎨 A command-line tool to generate GIF which can display sorting algorithm
Stars: ✭ 37 (+85%)
Mutual labels:  gif
luacc
Lua Code Combine
Stars: ✭ 36 (+80%)
Mutual labels:  loader

favloader

Favloader logo

npm MIT badge

Vanilla JavaScript library for loading animation in favicon that work when tab is not active.

See Demo

Why this library

Basic solution with animation using canvas don't work out of the box because of limitation of timer functions in Browsers' main Thread. The library use web worker to create timer that don't stop when tab is not in focus.

You can use this library if you have time consuming calculation and people switch tabs and you wan them to be notified when application finish whatever it was doing.

Installation

You can using webpack to include the files (using require) use local file in script tag:

<script src="favloader.js"></script>

you can also get the file from unpkg.com:

<script src="https://unpkg.com/[email protected]"></script>

API

Initialization

favloader.init({
    size: 16,
    radius: 6,
    thickness: 2,
    color: '#0F60A8',
    duration: 5000
});

All options are optional (those are the defaults).

Gif support

from version 0.3.0 the library support animating GIF in browsers that don't support gif files in link tag. The feature use AJAX and canvas. So gif file need to be on same domain or on domain that enabled CORS.

To create favicon loader using GIF file, you need to include parseGIF.js file:

<script src="https://unpkg.com/[email protected]/parseGIF.js"></script>

then init the library with GIF options, that point to GIF file (the GIF file is not scaled to match favicon, and was not tested on big GIF files).

favloader.init({
    gif: 'loader.gif'
});

Custom canvas animation

From version 0.4.0 you can use custom canvas animation

var p = 0;
var reversed = false;
var width = 2;
var size = 32;
favloader.init({
  size: size,
  frame: function(ctx) {
    ctx.fillStyle = '#F00A0A';
    ctx.fillRect(p, 0, width, size);
    if (reversed) {
      p--;
      if (p === 0) {
        reversed = false;
      }
    } else {
      p++;
      if (p === size - width) {
        reversed = true;
      }
    }
  }
});

Animation

Start animating

favloader.start();
favloader.stop();

Looks best if you don't have lot of tabs or if you do when tab is not in focus.

Limitation

To restore the icon properly, after stop, you need to include default favicon:

<link rel="icon" type="image/x-icon" href="favicon.ico"/>

Changelog

0.4.4

  • allow of multiple start before initialization

0.4.3

  • throw error when calling start before init

0.4.2

  • fix clear of animation when calling init when animation is running

0.4.1

  • README fix
  • add parseGIF.min.js file

0.4.0

  • canvas animation

0.3.1

  • fix for MacOSX/Chrome
  • fix initialization before DOM is ready

0.3.0

  • GIF animation support

0.2.2

  • option fix

0.2.1

  • npm fix

0.2.0

  • make it work without onload
  • change API options

0.1.0

  • inital version

License

Copyright (c) 2018-2019 Jakub T. Jankiewicz https://jcubic.pl/me

Released under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].