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

vue3-scroll-spy

v1.0.8

Published

<p align="center"><a href="https://tridiamond.tech" target="_blank" rel="noopener noreferrer"><img width="100" src="https://img-blog.csdnimg.cn/20200930013332450.png" alt="TriDiamond logo"></a></p>

Downloads

3,416

Readme

Demo | 📙 中文文档 | 📙 Changelog

Installation

npm i vue3-scroll-spy -S

OR

yarn add vue3-scroll-spy

Usage

Support

| Supported Package | Version | | ----------------- | ------- | | Vue | 3+ |

Install Directive

// global register at main.js
import { registerScrollSpy } from '@/directives/ScrollSpy'

const app = createApp(App)
// Using default options
registerScrollSpy(app)

// or custom global options
registerScrollSpy(app, options)

app.mount('#app')

On template

<ul v-scroll-spy-active v-scroll-spy-link>
  <li>
    <a>Menu 1</a>
  </li>
  <li>
    <a>Menu 2</a>
  </li>
</ul>

<div v-scroll-spy>
  <div>
    <h1>Header 1</h1>
    <p>Content</p>
  </div>
  <div>
    <h1>Header 2</h1>
    <p>Content</p>
  </div>
</div>

Configuration

v-scroll-spy

Binding scroll-spy to sections (or elements) of a container.

| Directive name | Description | Default | | --------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------ | | v-scroll-spy="{allowNoActive: true}" | When scroll position is outside of the container, active class will be removed. | Keep one section stays active at all time. | | v-scroll-spy="{offset: 50}" | TAdding offset to scroll and active elements. | Default: 0 | | v-scroll-spy="{time: 200, steps: 30}" | Set the animation options, time is animation duration, steps is step per frame. | {time: 200, steps: 30} |

v-scroll-spy-active

Setting active elements' selector and class properties.

| Directive name | Description | Default | | -------------------------------------------------------------------------- | ------------------------------------------- | ----------------------------------- | | v-scroll-spy-active="{selector: 'li.menu-item', class: 'custom-active'}" | Customize elements selector and class name. | {selector: null, class: 'active'} |

v-scroll-spy-link

Add click handler on children elements allow scrolling to the related section.

| Directive name | Description | Default | | ----------------------------------------------- | ------------------------------ | ----------------------------------- | | v-scroll-spy-link="{selector: 'a.menu-link'}" | Customize menu links selector. | {selector: null, class: 'active'} |

Bezier animations

import { registerScrollSpy, Easing } from '@/directives/ScrollSpy'

const app = createApp(App)

// or custom global options
registerScrollSpy(app, {
  easing: Easing.Cubic.In
})

app.mount('#app')

Note

  • You should have the same number of children elements for v-scroll-spy, v-scroll-spy-active, v-scroll-spy-link for this directive to work correctly.
  • If you need to share this scroll-spy directive on multiple containers, you can add data-scroll-spy-id="" on each element container, where this directive is bind.

Nested sections

Vue3 Scroll-Spy also support multi-leveled sections:

<ol
  v-scroll-spy
  v-scroll-spy-active="{selector: 'li.menu-item', class: 'active'}"
>
  <li class="menu-item">Item 1</li>
  <li class="menu-item">
    Item 2
    <ol>
      <li class="menu-item">Item 2.1</li>
      <li class="menu-item">Item 2.2</li>
    </ol>
  </li>
</ol>

Liscense

MIT License