An open API service indexing awesome lists of open source software.

https://github.com/hasielhassan/gifplayerjs

A libgif based Gif Player for JavaScript
https://github.com/hasielhassan/gifplayerjs

gif javascript player

Last synced: about 2 months ago
JSON representation

A libgif based Gif Player for JavaScript

Awesome Lists containing this project

README

        

# GifPlayerJS

![GifPlayerJS Preview](preview.gif)

GifPlayerJS is a lightweight JavaScript utility that converts standard `` elements pointing to `.gif` files into interactive, frame-by-frame GIF players with play/pause controls and a timeline slider. It leverages [libgif.js](https://github.com/kelyvin/libgif-js) under the hood to give you control over each GIF’s frames.

---

## Features

- **Play/Pause**: Easily toggle GIF playback.
- **Timeline Slider**: Scrub through frames to see specific parts of the GIF.
- **Fullscreen Mode**: Top right corner button on player to enter/exit fullscreen mode.
- **Auto-Initialization**: Automatically finds all `` elements whose `src` attribute ends in `.gif` (case-insensitive).
- **No External Dependencies**: Other than [libgif.js](https://github.com/kelyvin/libgif-js), you just need this single script to enable interactive GIF controls on your page.
- **Lightweight**: Straightforward and minimal code—perfect for small projects or demos.

## For the future:

- [ ] Implement proper CSS for styling of the playback controls
- [ ] Implement a proper Player class that encapsulates everything in a single div

---

## Getting Started

### 1. Include libgif.js and GifPlayerJS
In your HTML, make sure you include [libgif.js](https://www.jsdelivr.com/package/npm/libgif) **before** `gifplayer.js`:

```html

```

### 2. Initialize
After the page has loaded, call InitializeGifPlayers() to convert all .gif images into interactive players:

```html

window.addEventListener('load', InitializeGifPlayers);

```

### Example
Here’s a minimal working example (`example.html`):

```html


GifPlayerJS Example










// On load, initialize
window.addEventListener('load', InitializeGifPlayers);

```

### Technical notes

Since this project uses libgif, it also inheriths the `same-domain origin` restriction and must be loaded via a webserver, not directly from disk.

For more info reference the original notes on libgif: [caveat-same-domain-origin](https://github.com/kelyvin/libgif-js/?tab=readme-ov-file#caveat-same-domain-origin)