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

@xlaoyu/vue-scrollspy

v1.0.0

Published

Scrollspy for Vue2

Downloads

2

Readme

vue2-scrollspy

Vue 2.x npm npm-downloades license

Scrollspy, and animated scroll-to, for Vue2, extended vue2-scrollspy.

Features

  • Can specify scrolling containers, not just scroll window viewport

Installation

$ npm install @xlaoyu/vue-scrollspy --save

Setup

import Vue from 'vue';
import Scrollspy from '@xlaoyu/vue-scrollspy';
Vue.use(Scrollspy);

Usage

<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>

v-scroll-spy

Declares container of sections for elements to scrollspy.

  1. Use v-scroll-spy="{data: 'section'}" to add a section data property in scope Vue instance that is binded to the section index.

  2. Use v-scroll-spy="{allowNoActive: true}" to allow no active sections when scroll position is outside of the scrollspy container. Default behavior is too keep active at least one section in any case.

  3. Use v-scroll-spy="{offset: 50}" to add an offset for scroll and active events.

  4. Use v-scroll-spy="{time: 200, steps: 30}" to set the animation options.

  5. $scrollTo(index: int) is provided on scope Vue instance to invoke a scroll to the given section index.

  6. Use v-scroll-spy="{ container: '.right' }" specify scrolling containers, use document.querySelectorAll to find containers.

v-scroll-spy-active

Set the active css class on element that match the index of current scrollspy.

  1. Use v-scroll-spy-active="{selector: 'li.menu-item', class: 'custom-active'}" to customize elements selection and class name to apply. By default, it will use direct children and apply active class.

v-scroll-spy-link

Add click handler on children elements that will scroll to the related section.

  1. Use v-scroll-spy-link="{selector: 'a.menu-link'}" to customize elements selection. By default, it will use a to select all links.

Note

You should have the same number of children elements for v-scroll-spy, v-scroll-spy-active v-scroll-spy-link for directives to work properly.

If you need to share multiple scroll-spy in the same page, you can add data-scroll-spy-id="" on each element where a directive is declared.

If you want to set something else (not body) to scroll container, you could:

<div class="container" v-scroll-spy>
    <div>
        <h1>Header 1</h1>
        <p>Content</p>
    </div>
    <div>
        <h1>Header 2</h1>
        <p>Content</p>
    </div>
</div>
.container {
  position: relative;
}

Develop

npm i && npm run watch 
cd docs-src && npm i && npm run dev

License

MIT

Thanks to

ibufu