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

v4.3.0

Published

> trigger functions and events based on the element position on the screen

Downloads

38,680

Readme

VueWaypoint

trigger functions and events based on the element position on the screen

Latest Release

Demo

Simple demo page

Open your browser console and see what's going on while scrolling up and down

Features

  • [x] Vue 3
  • [x] No dependencies
  • [x] Flexible
  • [x] Typescript
  • [x] Battle tested
  • [x] Customizable
  • [x] Solid project (5+ years)
  • [x] Supports slots

Getting started

npm

npm i vue-waypoint

Vue component

<template>
  <Waypoint @change="onChange">
    <!-- anything you want here -->
  </Waypoint>
</template>
<script lang="ts">
  import { defineComponent } from "vue";
  import { Waypoint } from "vue-waypoint";

  export default defineComponent({
    name: "SomeComponent",
    components: {
      Waypoint,
    },
    setup() {
      const onChange = (waypointState) => {
        // Going can be:
        // IN
        // OUT
        console.log(waypointState.going);

        // Direction can be:
        // UP
        // DOWN
        // LEFT
        // RIGHT
        console.log(waypointState.direction);
      };

      return { onChange };
    },
  });
</script>

Props

active

  • [x] Can use a reactive variable
  • [x] Can set true/false dynamically

Usage:

  • Enable the waypoint: <Waypoint :active="true" />
  • Disable the waypoint: <Waypoint :active="false" />

options

Usage:

Options example:

const options: IntersectionObserverInit = {
  root: document,
  rootMargin: "0px 0px 0px 0px",
  threshold: [0.25, 0.75],
};

tag

  • [x] Set your preferred tag for the element

  • [x] Defaults to div

  • Waypoint as div: <Waypoint :tag="'div'" /> --> renders --> <div class="waypoint"></div>

  • Waypoint as span: <Waypoint :tag="'span'" /> --> renders --> <span class="waypoint"></span>

  • Waypoint as p: <Waypoint :tag="'p'" /> --> renders --> <p class="waypoint"></p>

disableCssHelpers

  • [x] Disable automatic CSS classes on the Waypoint component
  • [x] Defaults to false

Usage:

  • Enable helpers (default): <Waypoint :disableCssHelpers="false" />
  • Disable helpers: <Waypoint :disableCssHelpers="true" />

DOM result:

  • With CSS helpers: <Waypoint /> --> renders --> <div class="waypoint going-in direction-down"></div>
  • Without CSS helpers: <Waypoint :disableCssHelpers="true" /> --> renders --> <div></div>

CSS helpers

  • [x] Zero configuration needed
  • [x] Useful for simple CSS animations

The component comes with three classes:

  • waypoint: set when the waypoint is ready
  • going-in, going-out: dynamically changed when the waypoint comes in and out
  • direction-up, direction-down, direction-left, direction-right: dynamically changed when the direction changes

Examples:

  • <Waypoint class="waypoint going-in direction-up" /> - the element is visible and came from bottom and is going top (natural scroll)
  • <Waypoint class="waypoint going-in direction-down" /> - the element is visible and came from top and is going up (reverse natural scroll)
  • <Waypoint class="waypoint going-out direction-up" /> - the element is not visible and came from bottom and is going top
  • <Waypoint class="waypoint going-out direction-down" /> - the element is not visible and came from top and is going up

Events

change

Emitted every time the waypoint detects a change.

<template>
  <Waypoint @change="onChange" />
</template>
function onChange(waypointState) {
  /* ... */
}
interface WaypointState {
  el: Element;
  going: "IN" | "OUT";
  direction: "UP" | "DOWN" | "LEFT" | "RIGHT";
}

Development

  1. Fork the repository
  2. Run the project (npm i && npm run dev)
  3. Follow Conventional Commits spec for your commits
  4. Open a pull request

LEGACY: Vue2 and Nuxt version

vue-waypoint for Vue2 repository