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

panel-slider

v0.2.0

Published

Panel Slider

Downloads

3

Readme

Panel Slider

© by Mike Linkovich | www.spacejack.ca

Live demo

Install:

npm install panel-slider

Example Usage:

import PanelSlider from 'panel-slider'

const slider = PanelSlider({
	// The root element containing all panels
	element: document.querySelector('.my-panel-slider'),
	// Number of equal-sized panels
	numPanels: 3,
	// Starting panel
	initialPanel: 0
})

All Options:

interface PanelSliderOptions {
	/** The root element to use */
	element: HTMLElement
	/** Number of panels the root element is divided into */
	numPanels: number
	/** Starting panel */
	initialPanel?: number
	/** Duration of slide animation on release (default 500ms) */
	slideDuration?: number
	/** Horizontal distance threshold to initiate drag (default 12px) */
	dragThreshold?: number
	/** Minimum required horizontal:vertical ratio to initiate drag (default 1.5) */
	dragRatio?: number
	/** Input devices to enable (default ['mouse', 'touch']) */
	devices?: ('mouse' | 'touch')[]
	/**
	 * Optional custom animation interpolation function
	 * @param x0 Start coordinate
	 * @param x1 End coordinate
	 * @param t Time (0..1)
	 */
	terp?(x0: number, x1: number, t: number): number
}

Returned Interface:

interface PanelSlider {
	/** Add a listener that fires when drag starts */
	on(eventType: 'dragstart', cb: (d: Drag) => void): void
	/** Remove dragstart listener */
	off(eventType: 'dragstart', cb: (d: Drag) => void): void
	/** Add a listener that fires every move event while dragging */
	on(eventType: 'drag', cb: (d: Drag) => void): void
	/** Remove drag listener */
	off(eventType: 'drag', cb: (d: Drag) => void): void
	/** Add a listener that fires when drag ended */
	on(eventType: 'dragend', cb: (d: Drag) => void): void
	/** Remove dragend listener */
	off(eventType: 'dragend', cb: (d: Drag) => void): void
	/** Add a listener that fires when drag canceled */
	on(eventType: 'dragcancel', cb: (d: Drag) => void): void
	/** Remove dragcancel listener */
	off(eventType: 'dragcancel', cb: (d: Drag) => void): void
	/** Add a listener that fires every frame the panel moves */
	on(eventType: 'animate', cb: (panelFraction: number) => void): void
	/** Remove animate listener */
	off(eventType: 'animate', cb: (panelFraction: number) => void): void
	/** Add a listener that fires when animation starts or ends */
	on(eventType: 'animationstatechange', cb: (animating: boolean) => void): void
	/** Remove animationstatechange listener */
	off(eventType: 'animationstatechange', cb: (animating: boolean) => void): void
	/** Add a listener that fires when current panel has changed */
	on(eventType: 'panelchange', cb: (panelId: number) => void): void
	/** Remove panelchange listener */
	off(eventType: 'panelchange', cb: (panelId: number) => void): void
	/** Sets the current panel - animates to position */
	setPanel(panelId: number, done?: (panelId: number) => void): void
	/** Gets the current panel */
	getPanel(): number
	/** Gets the current root element & panel sizes */
	getSizes(): {fullWidth: number, panelWidth: number}
	/** Returns whether panels are currently being dragged or not */
	isDragging(): boolean
	/** Returns whether panels are currently animating or not */
	isAnimating(): boolean
	/** Destroy & cleanup resources */
	destroy(): void
}

Drag object provided to drag callbacks

export interface Drag {
	/** Horizontal amount dragged from start (in pixels) */
	x: number
	/** Current horizontal velocity */
	v: number
}