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 🙏

© 2026 – Pkg Stats / Ryan Hefner

svelte-turn-page

v0.1.1

Published

Svelte component library for modern page flipping books.

Downloads

50

Readme

svelte-turn-page

Svelte component library for page flipping books.

The fold is a port of turn.js (3rd release, Emmanuel Garcia) to TypeScript and Svelte 5 — the same fold geometry, the same gradients, the same tweener. The page lifts from a corner on hover, follows the pointer as you drag it, springs back if you let go short, and carries over if you drag past the far edge or click.

The package exposes Svelte components only. It does not bundle jQuery, vendored browser plugins, demo routes, or tests.

What the port keeps, and the one thing it does not

geometry.ts, animate.ts and flip.ts follow turn.js function for function: _fold's compute/transform, the linear-gradient shading, the cubic beziers a corner travels along, and animatef's fixed 30ms step with its circular ease-out. turn-engine.ts is turnMethods — page wrapping, views, ranges, calculateZ, single and double display.

The one deliberate difference: turn.js evicts pages from the DOM to keep only six alive, and it owns the elements it evicts. Here Svelte owns them, so pages outside the view are hidden rather than removed, and a MutationObserver re-wraps whatever Svelte adds or takes away.

Install

npm install svelte-turn-page

This package expects Svelte 5 from the consuming application.

Usage

<script lang="ts">
	import { TurnBook, TurnPage, type TurnBookApi } from 'svelte-turn-page';

	let api: TurnBookApi | undefined;
	let page = 1;
</script>

<TurnBook bind:api bind:page width={900} height={560} display="double">
	<TurnPage>
		<h2>Cover</h2>
	</TurnPage>

	<TurnPage>
		<h2>Inside page</h2>
	</TurnPage>
</TurnBook>

<button type="button" onclick={() => api?.previous()}>Previous</button>
<button type="button" onclick={() => api?.next()}>Next</button>

API

TurnBook props:

  • width, height: fixed pixel dimensions for the book.
  • page: bindable current page.
  • display: 'single' or 'double'.
  • pages: optional total page count for dynamic pages.
  • gradients, duration, cornerSize, corners: visual and interaction options.
  • disabled: locks or unlocks interaction.
  • api: bindable imperative component API.
  • onready, onturn, onturning, onturned, onfirst, onlast, onstart: Svelte 5 callback props.

Pages peel when a pointer enters an enabled corner. Press and drag to control the fold, then release to complete or cancel the turn. Keyboard and imperative turns use the same fold renderer.

TurnBookApi methods:

next, previous, page, pages, view, range, size, display, configure, resize, update, disable, stop, animating, hasPage, addPage, removePage, and destroy.

Scripts

npm run check
npm run build
npm run package
npm run lint

npm run build packages the Svelte source and adds ESM/CJS TypeScript bundles with tsdown. npm run lint runs Svelte checks, builds the library, and validates the package exports with publint.

License

The original turn.js license is retained in LICENSE.md.