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

snakle.js

v1.0.0

Published

Snake loader animation around the viewport borders.

Downloads

3

Readme

Snakle.js

Javascript library using Canvas - Snake loader animation around the viewport borders.

Try the Demo samples.

Getting Started

  1. Installation
  2. Usage
  3. Options
  4. API / Events
  5. Browser Support

Installation

Using NPM

Not published yet

npm i snakle.js --save

jsDelivr CDN

Not published yet

<script src="https://cdn.jsdelivr.net/snakle.js/1.0.0/snakle.js"></script>

Usage

// ES6 module import
import Snakle from 'snakle.js' // not required if using a CDN or directly include

// instantiate with options
const snake = new Snakle('#selector', { /* options here */ })

// initiate and draw the snake
snake.init()

// play animation
snake.play()

Options

Settings overview list:

Snakle('#selector', {
    thickness: 22,
    color: 'red',
    length: 10,
    speed: 15
})

Option details are detailed below.

Option | Type | Default | Description ---|---|---|--- thickness | integer | 22 | Thickness of the snake body (the snake body is made of multiple squares, where thickness represents the width and height of each square). color | string or array | red | Color of the snake body (RGB or hexadecimal). Can be a single color #3498db, or a two colors gradient by using a array[2] ['red', 'blue']. length | integer | 10 | Length of the snake body or tail length (also represents the number of squares that the body is made of). speed | integer | 15 | Speed of the snake animation (FPS).

API / Events

Snakle exposes the following methods, and events:

Note that all methods are chainable, and all events includes on, off, and once.

.init()

Used to generate the snake and draw it into the viewport.

snake.init()
snake.on('init', () => { /* callback here */ })

.play()

Used to play the snake animation.

snake.play()
snake.on('play', () => { /* callback here */ })

.pause()

Used to pause the snake animation.

snake.pause()
snake.on('pause', () => { /* callback here */ })

.reset()

Used to reset the snake position to it's initial state.

snake.reset()
snake.on('reset', () => { /* callback here */ })

.stop()

Used to stop the snake animation. Equivalent to .pause() + .reset().

snake.stop()
snake.on('stop', () => { /* callback here */ })

.destroy()

Used to completely remove the snake from the selector. Restore the initial state.

snake.destroy()
snake.on('destroy', () => { /* callback here */ })

draw

Emitted each time the snake is re-drawn into the viewport during animation.

snake.on('draw', () => { /* callback here */ })

resize

Emitted each time the snake is re-drawn after a resize of the viewport.

snake.on('resize', () => { /* callback here */ })

Browser Support

Snakle is fully supported by Evergreen Browsers (Edge, Opera, Safari, Firefox & Chrome) and IE 11.

License

MIT © 2016 Sylvain Simao

Built With Love