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

@pluve/scroll-anchor

v1.1.8

Published

## 安装 ```bash npm install @pluve/scroll-anchor

Downloads

26

Readme

Scroll Anchor

安装

npm install @pluve/scroll-anchor

yarn add @pluve/scroll-anchor

组件介绍

H5平台的双向锚点组件,可以为页面滚动提供锚点定位,提供功能包括

  • 双向锚点
  • 自动吸顶
  • 动态高度支持
  • 内容嵌套

使用


const navKey = [
      { key: 'h1', name: 'test1' },
      { key: 'h2', name: 'test2' },
      { key: 'h3', name: 'test3' },
      { key: 'h4', name: 'test4' },
      { key: 'h5', name: 'test5' },
      { key: 'h6', name: 'test6' },
      { key: 'h7', name: 'test7' },
    ];

        <ScrollAnchorWrapper>
            <ScrollAnchor>
              <!-- other view -->
              <ScrollAnchorNavBar navData={navKey} fixedPosition={0} />
              <ScrollAnchorItem scrollKey="h1">
                <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h2">
                <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h3">
               <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h4">
                <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h5">
                <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h6">
                <div>you content</div>
              </ScrollAnchorItem>
              <ScrollAnchorItem scrollKey="h7">
                <div>you content</div>
              </ScrollAnchorItem>
            </ScrollAnchor>
          </ScrollAnchorWrapper>

以上为组件的使用方式,组件内部使用Context维护数据,默认情况下,只使用单一数据源,即默认KEY使用, 在嵌套模式下,需要进行Key的指定,即同时存在多个 ScrollAnchor的情况下,需要指定anchorKey

<ScrollAnchor anchorKey='details'>
...
</ScrollAnchor>

ScrollAnchorItem中同样需要使用belongTo来指定归属关系

<ScrollAnchorItem scrollKey="h1" belongTo='details'>
...
</ScrollAnchorItem>

在组件ScrollAnchorItem中,scrollKey用于指定锚点,需要和导航内的key对应

示例

项目Demo