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

lazy-line-painter

v2.0.3

Published

A Modern JS library for SVG path animation

Downloads

647

Readme

Lazy Line Painter

Getting Started

Lazy Line Painter Lazy Line Painter can be setup with minimal effort as per the Quick Start instructions. However if a GUI is more your thing, be sure to use the Lazy Line Composer. A free Online Editor developed specifically for SVG path animation.

NPM
pnpm i lazy-line-painter
CDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/lazy-line-painter-2.0.3.min.js"></script>
DOWNLOAD
<script src="./libs/lazylinepainter-2.0.3.js"></script>

Quick Start

The most basic, no-frills implementation;

// import LazyLinePainter
import LazyLinePainter from "lazy-line-painter";

// select your svg
const el = document.querySelector("#my-svg");

// initialise & configure LazyLinePainter
const myAnimation = new LazyLinePainter(el, { strokeWidth: 10 });

// paint! :)
myAnimation.paint();

Documentation

Configuration

Configure on initialisation

On initialise you can pass lazylinepainter a config object as an argument containing the attritubes you wish to alter across the entire svg. All config properties are optional. Style attributes set in the config will override css styles.


const config = {

	// style properties
	'strokeWidth'     // Adjust width of stroke
	'strokeColor'     // Adjust stroke color
	'strokeCap'       // Adjust stroke cap  - butt  | round | square
	'strokeJoin'      // Adjust stroke join - miter | round | bevel
	'strokeOpacity'   // Adjust stroke opacity 0 - 1
	'strokeDash'      // Adjust stroke dash - '5, 5'

	// animation properties
	'delay'           // Delay before animation starts
	'reverse'         // reverse playback
	'ease'            // penner easing - easeExpoOut / easeExpoInOut / easeExpoIn etc
	'repeat'          // number of additional plays, -1 for loop
}

const svg = document.querySelector('#my-svg')
const myAnimation = new LazyLinePainter(svg, config)
Configure individual paths

Data attributes can be used to configure style & animation properties on individual paths in the SVG. Data attributes will override both css styles & initialisation config style attributes.

<path 

  // style 
  data-llp-stroke-width="10"
  data-llp-stroke-color="#000000"
  data-llp-stroke-opacity="0.5" 
  data-llp-stroke-cap="rounded" 
  data-llp-stroke-join="mitre" 

  // animation
  data-llp-stroke-dash="[2,2]" 
  data-llp-duration="200" // (ms)
  data-llp-delay="200" // delay offset from start of timeline (ms)
  data-llp-reverse="true" (default = "false") 
  data-llp-ease="easeInOutQuad" (default = 'easeLinear') 

  />

API Reference

Methods

Paint - accepts optional playback arguments - reverse, ease, delay

const reverse = true;
const ease = "easeExpoOut";
const delay = 200;
myAnimation.paint({ reverse, ease, delay });

Erase - paint can still be called on the element after it has been erased;

myAnimation.erase();

Pause

myAnimation.pause();

Resume

myAnimation.resume();

Progress

// set - [0 - 1]
myAnimation.progress(value);

// get
const progress = myAnimation.progress();
console.log(progress);

Destroy - destroys svg & lazyline instance

myAnimation.destroy();

Events

Handle events across entire animation
myAnimation.on("start", () => {});
myAnimation.on("update", () => {});
myAnimation.on("complete", () => {});
Handle all events

Called for each shape animated within the svg. event argument contains shape properties.

myAnimation.on('start:all', (event) => {});
myAnimation.on('update:all', (event) => { console.log(event.progress); // [0-1] });
myAnimation.on('complete:all', (event) => {});
Handle targeted events.

Listen to events on specific shapes by adding the shape-id after the colon. event argument contains shape properties.

myAnimation.on("start:id", (event) => {});
myAnimation.on("update:id", (event) => {});
myAnimation.on("complete:id", (event) => {});
Timeline playback events
myAnimation.on("pause", () => {});
myAnimation.on("resume", () => {});
myAnimation.on("erase", () => {});

Examples

Changelog

Refer to Release notes for entire Changelog

Author

https://merriment.info/