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

non-hash-anchor

v0.0.3

Published

非hash模式的锚点功能实现,可以检测滚动过程中元素是否处于曝光状态,还可以通过点击锚点滚动到制定元素位置

Downloads

4

Readme

non-hash-anchor

非hash模式的锚点功能实现,可以检测滚动过程中元素是否处于曝光状态,还可以通过点击锚点滚动到制定元素位置

该组件解决了使用 hash router 时无法使用 hash anchors 的问题

案例演示

查看案例演示

安装

yarn add non-hash-anchor
# 或者
npm install non-hash-anchor --save

用法

html

需要在列表中设置data-anchor属性(唯一性),对应的值与菜单一一对应。

<div class="tabs">
  <div class="tab-item anchor1">anchor1</div>
  <div class="tab-item anchor2">anchor2</div>
  <div class="tab-item anchor3">anchor3</div>
</div>
<div class="scroll-container">
  <h2 class="text-center">scroll-container</h2>
  <div class="top-content extra-content">
    top content
  </div>
  <div class="anchor-container">
    <h3 class="anchor-item" data-anchor="anchor1">anchor1</h3>
    <h3 class="anchor-item" data-anchor="anchor2">anchor2</h3>
    <h3 class="anchor-item" data-anchor="anchor3">anchor3</h3>
  </div>
  <div class="bottom-content extra-content">
    bottom content
  </div>
</div>

javascript

var anchor = new Anchor(document.querySelector('.anchor-container'), {
  scrollContainer: document.querySelector('.scroll-container'),
  onChange(anchor) {
    // TODO...eg: 设置tab的选中状态
    console.log(Date.now(), anchor)
  },
  onExposure(anchors) {
    // TODO...eg: 获取数据
    console.log(anchors)
  },
});
var tabs = document.querySelectorAll('.tab-item');
tabs.forEach(function (item) {
  item.addEventListener('click', function () {
    anchor.scrollTo(item.innerText)
  })
});

API

| 名称 | 说明 | 类型 | 必传 | 默认值 | | - | - | - | - | - | | container | 列表容器 | HTMLElement | true | - | | options | 其他参数 | HTMLElement | false | Object |

Options

| 名称 | 说明 | 类型 | 必传 | 默认值 | | - | - | - | - | - | | scrollContainer | 滚动容器 | HTMLElement | false | document.documentElement | | offsetTop | 滚动结束后距离滚动容器顶端的距离 | number | false | 0 | | isDynamic | 列表是否会动态增删 | boolean | false | false | | onChange | 当前选中项发生变化时的回调事件 | function (anchor:string) {} | false | - | | onExposure | 当前选中项发生变化时的回调事件 | function (anchors:string[]) {} | false | - |

License

MIT