npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flicker

v1.1.5

Published

Create beautiful, seekable, mobile-friendly-auto-playable HTML videos (faked with sprite animations and canvas).

Downloads

12

Readme

flicker

Create beautiful, seekable, mobile-friendly-auto-playable HTML videos (faked with sprite animations and canvas).

Demo: flicker.jonathan-brooks.co.uk

Install

Why?

I basically didn't like HTML video limitations on mobile (specifically no autoplay for hero backgrounds), so I figured a good solution would be to use sprite animations - but packing the sprites and converting the frame coords to JSON with an external tool took forever, and I wanted to play/pause/reverse/seek my sprite animations easier. So I made a tool which does both. Essentially, my pipeline was as follows:

Useage - Step 0 - Generating image sequences for packing

This step, namely converting your video into an image sequence, is at your discretion. Here are a couple possible methods:

Useage - Step 1 - Packing the image sequences into sprites

After running npm install flicker, you should notice the following folders in the package directory:

Before running the flicker app, you'll need to move your image sequences into the sequences/ folder. Each sequence should be stored within it's own folder, resembling the following:

Then run npm start from the package directory - this process can take a little while, depending on the amount of images being packed into sprites. After it's finished, your packed sprites and the JSON map representing the entire animation (both sequence1 and sequence2 combined) will be inside flicker/:

Useage - Step 2 - Using the sprites in your HTML

You can find an example by heading to flicker.jonathan-brooks.co.uk and viewing the page source, but I'll include a snippet on it's set up here:

Defining a flicker context

Quick note, the canvas width and height attributes have been set according to the native size of each image in the sprite (each image is the same size, as they're all derived from the same video). Make sure to do this for your canvas too - then scaling it is as easy changing the width/height in CSS.

Additionally, the following snippet has a .controls range slider which acts as a seek control for the flicker. At a later date I'll document how you can replace this with your own custom implementation using the Flicker.seek() function.

Creating and configuring an instance of the flicker object

The js setup in this snippet is (thus far) as complicated as the config gets. I'll be adding additional features in the future, like additional event handlers, and more config options like playThrough (pausing between sequences) and show/hide default seek controls

Notes

It should be noted that this tool is very much in pre-production, and as such it's still pretty limited. Here are some of the issues I'll be working on henceforth:

  • At the moment, because the sprite packer tries to process all the sequences at once, it falls over if the sequences are too long (and they often are - 24 images = 1 second of video after all). This fix is a priority and will come soon.
  • In testing the images package (which flicker depends on for sprite packing), I found that somewhat arbitrarily it falls over when the sprite resolution roughly exceeds 10,000 x 10,000 pixels. Again, I will do some investigating into why this limit exists and see if I can work around it with some crafty image compression (or something similar).
  • At the moment you have to manually separate the huge monolithic image sequences you get from the video export manually - at some point in the future I'm hoping to add custom CLI parameters/JSON config file which let you specify when to cut the sequence into sub-sequences at given points in time (specified in frames or seconds from the beginning of the video).

If you have any questions, or wish to contribute, then don't hesitate to contact me!

Happy coding everyone ♥