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

@bfchain/virtual-scroll

v1.6.0

Published

[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/owner/my-element)

Downloads

62

Readme

Virtual Scroll - WebComponent

Published on webcomponents.org

DEMO

Usage

Install Dep

npm i @bfchain/virtual-scroll --save
yarn add @bfchain/virtual-scroll

moderns web dev

For Angular/React/Vue/Preact etc.

import "@bfchain/virtual-scroll";

or include directly

For vanillajs

<script src="./node_modules/@bfchain/virtual-scroll/dist/vitrual-scroll.iife.js"></script>

then you can use the component in your html

<scroll-viewport>
  <fixed-size-virtual-list-s1
    id="l"
    item-size="200"
    item-count="1000000"
    safe-area-inset-top="400"
    safe-area-inset-bottom="100"
    onrenderrangechange="rangeChange(event)"
  >
    <div class="block-card-item" slot="template">
      <div class="block-content">
        <div class="height">Height: <span name="height"></span></div>
      </div>
      <div class="chain-link"></div>
    </div>
    <virtual-list-custom-item item-size="400">
      <div class="my-sliders">
        <div class="slider-item">This is Banner!</div>
      </div>
    </virtual-list-custom-item>
    <virtual-list-custom-item position-top="800" item-size="200">
      <div class="my-sliders">
        <div class="slider-item">rethink, this is grid.</div>
      </div>
    </virtual-list-custom-item>
  </fixed-size-virtual-list-s1>
</scroll-viewport>

Document

  1. <scroll-viewport>

    viewport for virtual scroll.

    • @slot - This element has a slot
  2. <fixed-size-virtual-list-s1>/<fixed-size-virtual-list-s2>

    virtual scroll list with fixed size.

    • s1 means has only one scrollbar to capture two direction scroll.
    • s2 means has two scrollbar for two direction scroll (maybe you will need it).
    • @slot - for custom list item
    • @slot template - for buildable item
    • @csspart scroll-ctrl - (s1) the scroll controller
    • @csspart scroll-up - (s2) the scroll up controller
    • @csspart scroll-down - (s2) the scroll down controller
    • @csspart virtual-list-view - the scroll item container
    • @fires renderrangechange - when scroll, the item will need render changed
    • @attr {bigint} item-count -
    • @attr {number} item-size -
    • @attr {number} safe-area-inset-top - like padding-top
    • @attr {number} safe-area-inset-bottom - like padding-bottom
    • @attr {number} cache-render-top - will make list-view higher, for render more item. if item content overflow, you may need change this to make it render correctly
    • @attr {number} cache-render-bottom - will make list-view higher, for render more item. like {cache-render-top}
    • @method refresh() - if you change the attr directly by set property. you may need call the method
    • @prop {bigint} virtualScrollTop - change the scroll top. without animation
  3. <virtual-list-custom-item>

    custom item in virtual scroll list

    • @slot - for custom list item
    • @attr {bigint} position-top - the posiction in virtual scroll list
    • @attr {number} item-size - the item height

ISSUES

  1. because of scroll-ctrl behavior base on scroll-snap, but Firefox and WebKit don't behave the same. so in firebox you need use controlbar but no mousewheel.

TODO

  • [x] fixed-size-virtual-list 重构成 LitElement
  • [x] 抽象出 common-fixed-size-virtual-list-builder 以扩展多种不同滚动策略
  • [ ] fixed-size-virtual-list 需要正确区分 create / visible / hidden / destroy 四种状态
  • [ ] create 与 destroy 发生的时候,如果该元素不在页面中,不应该发生滚动
  • [ ] 实现 pushCount(newCount:bigint), insertCount(newCount:bigint, refIndex = 0n)
  • [ ] 实现 scrollToIndex(index:bigint)
  • [ ] 支持 scroll-behavior: smooth
  • [x] 滚动的平滑衰减应该基于帧时间而不是基于帧数