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

@howdyjs/scroll

v2.1.2

Published

自定义滚动条插件

Downloads

12

Readme

Scroll

Version Size

自定义滚动条插件

特性

  1. 通过配置项生成自定义样式的滚动条
  2. 支持拖拽滚动
  3. 基本不需要更改DOM布局,只需在overflow:scroll的元素上增加该指令即可
  4. 移动端中无效,会自动改回默认的滚动
  5. 封装了vue指令的形式
  6. 使用ResizeObserver监听盒子大小变化,已无需手动调用update方法(^2.1.2)

原生使用

import CustomScrollBar from '@howdyjs/scroll'
const scroll = new CustomScrollBar({
  el: '#scroll', // Selector or Dom
  options: {
    // Your Options
    // 参考下方说明
  }
});
scroll.init();
  • UMD CDN: https://unpkg.com/@howdyjs/scroll/dist/index.umd.js
  • UMD Name: HowdyScroll

Options (Objcet)

|参数|说明|类型|可选值|默认值| |:---|:---|:---|:---|:---| |direction|滚动条方向|String|x/y/all|y| |scrollBarWidth|滚动条宽度(轨道)|Number|-|6| |scrollBarOffsetX|滚动条水平偏移(padding)|Number|-|0| |scrollBarOffsetY|滚动条垂直偏移(padding)|Number|-|0| |scrollBarThumbColor|滚动条滑块颜色|String|-|#aab| |scrollBarThumbBorderRadius|滚动条滑块是否需要圆角|Boolean|-|true| |scrollBarThumbBorderRadius|滚动条轨道颜色|String|-|transparent| |scrollBarThumbHoverColor|滚动条滑块Hover时的颜色(默认不设置)|String|-|-| |enableTrackClickScroll|是否允许点击轨道进行滚动|Boolean|-|true| |scrollSpeed|点击轨道时的滚动速度(滚动效果使用requestAnimationFrame实现,该值表示每帧的位移量,单位PX)|Number|-|20| |dragScroll|是否开启拖拽滚动|Boolean|-|false| |thumbShow|滚动条滑块显示方式,可选一直显示与Hover显示|String|always/hover|always| |observeAutoUpdate|自动更新滚动条,默认开启,若关闭则需要自行在盒子大小改变时手动调用更新方法|Boolean|-|true|

长度属性的单位为px

以Vue指令方式使用

import { ScrollDirective } from '@howdyjs/scroll'
// Vue3全局引入
app.use(ScrollDirective, someGlobalOptions)

// Vue2全局引入(对vue2做了兼容)
Vue.use(ScrollDirective, someGlobalOptions)

// 组件内引入
export default {
  directive: {
    scroll: ScrollDirective
  }
}

指令Arg

  1. y(默认), 开启垂直滚动
  2. x, 开启水平滚动
  3. all, 同时开启垂直、水平滚动

v-scroll:y | v-scroll:x | v-scroll:all

指令Value (Objcet)

参数同上方的配置Options