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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nimble-ui/scrollbar

v1.0.0

Published

滚动插件

Readme

nimble-ui scrollbar 封装滚动插件

📢 介绍

nimble-ui scrollbar 封装滚动插件

⚡ 使用说明

安装依赖

npm i @nimble-ui/scrollbar
# or
yarn add @nimble-ui/scrollbar
# or
pnpm i @nimble-ui/scrollbar

使用

<template>
  <div ref="warpRef" class="warp">
    <div ref="contentRef" class="content">
      <div
        v-for="item in list"
        :key="item.id"
        :data-drag-id="item.id"
        class="move css"
      >
      {{ item.title }}
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, onBeforeUnmount } from 'vue';
import { scrollbar } from "@nimble-ui/scrollbar"

defineOptions({ name: 'move' });
const list = reactive([
  { id: 1, title: '测试1' },
  { id: 2, title: '测试2' },
  { id: 3, title: '测试3' },
  { id: 4, title: '测试4' },
  { id: 5, title: '测试5' },
  { id: 6, title: '测试6' },
  { id: 7, title: '测试7' },
  { id: 8, title: '测试8' },
  { id: 9, title: '测试9' },
  { id: 10, title: '测试10' },
]);

setTimeout(() => {
  list.push({id: 11, title: "测试11"})
}, 3000)

const warpRef = ref<HTMLElement>();
const contentRef = ref<HTMLElement>();
const getEl = () => warpRef.value;
const { destroy } = scrollbar(getEl, {
  content: () => contentRef.value!,
})
onBeforeUnmount(destroy)
</script>

<style lang="scss">
.warp {
  width: 500px;
  height: 400px;

  .move {
    width: 150px;
    height: 50px;
  }
}
</style>

scrollbar 参数

| 属性名 | 说明 | 类型 | 默认 | | ------- | -------- | ----------------------- | ---- | | el | 元素 | element | () => element | - | | options | 参数 | ScrollOptions | - |

ScrollOptions属性

interface ScrollOptions {
  // 总是显示
  always?: boolean;
  // 最小尺寸
  minSize?: number;
  // 内容元素 必填
  content: Element | (() => Element);
  // 当触发滚动事件时,返回滚动的距离
  onScroll?: (data: { scrollLeft: number; scrollTop: number }) => void;
}

scrollbar 暴露方法

| 属性名 | 说明 | 类型 | | ------------- | ---------------- | ------------------------------------------------------------ | | scrollTo | 滚动到一组特定坐标 | (options: ScrollToOptions | number, yCoord?: number) => void | | setScrollSite | 设置滚动条的距离 | (scrollLeft: number, axis: 'x' | 'y') => void | | thumbColor | 设置滚动条的颜色 | (color: string) => void | | destroy | 销毁绑定事件等 | () => void |