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

scrolling-controller

v0.1.2

Published

> * 下拉列表滚动控制器 > * 支持控制每次滚动落点相对位置与上一落点相同 > * 支持任意高度的着点元素,或者不同高度的着点元素 > * 支持循环选中

Downloads

6

Readme

ScrollingController

  • 下拉列表滚动控制器
  • 支持控制每次滚动落点相对位置与上一落点相同
  • 支持任意高度的着点元素,或者不同高度的着点元素
  • 支持循环选中

使用方式

npm install scrolling-controller

    import ScrollingController from 'scrolling-controller'

    let scrolling_controller = new ScrollingController(
        scroll_view, //任意 overflow-y: auto; 容器
        {
            mesh_value: 1,  //mac平台 mouseMove 事件监听范围超出监听容器大小1px左右(估计是超高分辨率所致),这个值用于配置监听冗余兼容的范围(默认为1)
            throttle: 80,   //默认不启用节流,true 为默认值 80 ms,可以指定任意毫秒值(0.0.3之后这个值也用于滚轮 delta 值的节流)
            mark: "gallery-item",   //指定做了 data-type={mark} 标记的可着点元素
            onSelected(index){}  //每次选择更改都会被回调
        }
    );

    window.addEventListener("keydown", (e) => {
        switch (e.key) {
            case "ArrowUp":
                scrolling_controller.prevChoice()   //选中上一项,如果没有上一项则选中最后一项
                break;
            case "ArrowDown":
                scrolling_controller.nextChoice()   //选择下一项,如果没有下一项则选中第一项
                break;

        }
    });

    scrolling_controller.index = 3; //直接更改当前选中项