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

v-scroll-active

v0.0.7

Published

A lightweight vue component for making navigation elements active as you scroll.

Downloads

118

Readme

v-scroll-active

npm file size Build Status

A vue component for making navigation elements active as you scroll, a wrapper of scroll-active .

在滚动时激活对应导航的 vue 组件,封装自 scroll-active

Live Demo

live demo

Installation

npm install v-scroll-active --save

Usage

<!-- nav bar -->
<div class="navbar">
    <VScrollActive offset="40" :hash="true" @update="handleNavbarChange">
        ...
        <span data-scroll-active="menuOne">menu one</span>
    </VScrollActive>
</div>

<!-- main page -->
<div class="container">
    ...
    <div id="menuOne"></div>
</div>
// window
// const VScrollActive = window['VScrollActive'];
// commonjs like
// const VScrollActive = require('v-scroll-active');
// es module, typescript
import VScrollActive from './VScrollActive.vue';

// Vue.use(VScrollActive); // global

export default {
    components: {
        VScrollActive // local
    },
    methods: {
        handleNavbarChange(id) {
            console.log('current active id is ' + id);
        }
    }
};

Add data-scroll-active to the navigation menu and assign an element id. When the page scrolls to the element, it will add active to the class of the navigation menu.

At the same time, clicking the navigation menu will also make the page scroll to the corresponding element position.

在导航菜单上添加 data-scroll-active ,赋值一个元素 id,在页面滚动到该元素的时候,就会给导航菜单的 class 添加 active

同时点击该导航菜单也会让页面滚动到对应元素位置。

Props

| name | type | default | description | | :---------- | :-------: | :------: | :--------------------------------------------------------------- | | activeClass | string | active | class used for navigation activation 导航激活时使用的 class | | offset | number | 0 | offset used to activate navigation 距离激活导航使用的偏移量 | | hash | boolean | false | offset used to activate navigation 距离激活导航使用的偏移量 |

Event

| name | arguments | description | | :----- | :-------: | :-------------------------------------------------------------------------------: | | update | id | event emit when a navigation change is active 在激活的导航变更时,触发的事件 |

Enjoy it! :D