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

vue-active-tracker

v0.1.1

Published

A Vue.js scroll sensor component useful to activate your nav links

Downloads

7

Readme

What are we talking about

This component simply let you change the class of your nav links depending on what element is in the view right now. This component should wrap you navigation and every link should have a reference a section of interest. See examples below..

How to install

npm install vue-active-tracker

How to use

import App from './App.vue';
import VActiveTracker from 'vue-active-tracker';
import Vue from 'vue';

Vue.use(VActiveTracker);

new Vue({
  render: h => h(App),
}).$mount('#app');

or without plugin initialization...

<template>
    <v-active-tracker>
        <nav>
            <ul>
                <li>
                    <a href="#first">First link</a>
                </li>
                <li>
                    <a href="#second">Second link</a>
                </li>
                <li>
                    <a href="#third">Third link</a>
                </li>
            </ul>
        </nav>
    </v-active-tracker>


    ...

    <section id="first">
        First section
    </section>

    <div id="second">
        Second section
    </div>

    <footer id="third">
        Third section
    </footer>
</template>

<script>
import VActiveTracker from 'vue-active-tracker';

export default { 
  components: {
    VActiveTracker
  }
}
</script>

Props

  • link-selector it is the selector used for finding nav links

    • type: String,

    • default: a

      Define the selector used to find links (the search is limited for those links defined inside this component). See CSS selectors for more info. Examples: a, a.link, button[data=foo], ...

  • active-class

    • type: String,

    • default: is-active

      Define which class (or classes) should be added when the link becomes active.

  • trigger

    • type: String,

    • default: top

      Define where do you want to place your trigger.. Possible values are the following

      • top set the trigger at the top of the screen view (it is equivalent to 0% or 0)
      • middle set the trigger at the vertical center of the screen view (its is equivalent to 50%)
      • bottom set the trigger at the bottom of the screen view (its is equivalent to 100%)
      • {number}px set the trigger {number} pixel from the top. Examples: 100px, 40px, 10px, ...
      • {number} equivalent of {number}px. Examples: 100, 40, 10, ...
      • {percentage}% set the trigger {percentage} percentage from the top where 0% means top and 100% means bottom. Examples: 10%, 20%, 30%, ...
  • auto-start

    • type: Boolean,

    • default: true

      When set to true the componets gets updated even when it is mounted the first time. Otherwise it will only update automatically when you resize window. You should always let this prop true.

Methods

  • update()

    Use this method to re-bind links and sections as they are added to the DOM. The component, however, will auto udate whenever the page get resized.

Doubts ?

  • Doesn't work with conditionally displayed links

    Try by using the update method after having added the link you want to the page.

License

MIT @ Davide Turrini (davide-turrini)