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

@byte.n/scroll-frame-canvas

v1.1.0

Published

基于滚动条驱动的 Canvas 帧序列渲染器,支持渐进式大序列加载、OffscreenCanvas 预渲染与事件回调。

Readme

npm version

scroll-frame-canvas

一个基于滚动条驱动的 Canvas 帧序列渲染器。支持超大序列的渐进式加载(分层预取)、OffscreenCanvas 预渲染、contain/cover/fill 缩放、滚动轴映射、自定义加载动画与事件回调,适用于产品页沉浸式滚动动画、分镜头切换与高分辨率影像浏览。

功能特性

  • 渐进式加载:通过 large.factor 分层取样,先快后全,体验流畅
  • OffscreenCanvas 预渲染:将图片转换为 ImageBitmap,渲染更高效
  • 任意滚动轴:xy,由 frameMapper 精确映射到帧索引
  • 多种缩放:contain / cover / fill
  • 事件系统:framecompleteinitCompleteerror
  • 自定义加载动画:主加载与背景层加载均可自定义绘制
  • 并发控制与重试:maxConcurrentLoads

文档 & Demo:https://byte-n.github.io/scroll-frame-canvas/


安装

pnpm add @byte.n/scroll-frame-canvas
# 或
npm i @byte.n/scroll-frame-canvas
# 或
yarn add @byte.n/scroll-frame-canvas

快速开始

import ScrollFrameCanvas from '@byte.n/scroll-frame-canvas'

const canvas = document.querySelector('canvas')!

const sfc = new ScrollFrameCanvas({
  canvasEle: canvas,
  scrollbarEle: window,
  scrollAxis: 'y',
  // 传入完整数组,或使用 total + imageFactory
  total: 281,
  imageFactory: (index) => `/images/frame-${String(index + 1).padStart(3, '0')}.jpg`,
  scaleMode: 'contain',
  large: { enabled: true, factor: 16, showBackgroundProgress: true },
  maxConcurrentLoads: 8,
  frameMapper: (scrollPixels, totalScrollPixels, totalFrames) => {
    const ratio = totalScrollPixels ? scrollPixels / totalScrollPixels : 0
    return Math.round(ratio * (totalFrames - 1))
  },
  onInitComplete: () => console.log('初始化完成'),
  onError: (e) => console.error(e),
})

await sfc.init()
sfc.play()

常见问题

  • 关于大序列:开启 large.enabled 后会分层取样,先加载关键帧,随后后台补齐,保证首屏可用与流畅度。
  • 关于 frameMapper:请根据页面可滚动距离与交互节奏自定义映射关系。
  • 跨域图像:从 URL 加载时设置了 crossOrigin = 'anonymous',请确保 CDN 允许跨域。

本地开发与示例

pnpm i
pnpm dev
# 打开 http://localhost:8080 查看 demo

License

MIT