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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-collision

v2.0.1

Published

fires a collide/non-collide event on collision with viewport or any other bounding box

Readme

vue-collision

Vue 3 directive that fires collide / non-collide events when an element enters or leaves the viewport, plus element-to-element group collision detection via AABB.

CI npm version License: MIT

Features

  • Viewport collision via IntersectionObserver — zero-cost, edge-triggered
  • Element-to-element group collision via rAF + AABB overlap — groups any number of elements and checks every pair
  • Fires native DOM CustomEvents (collide, non-collide, collide-<group>, non-collide-<group>)
  • Grouping: place elements in named groups; any pair within a group is checked
  • .prevent modifier to opt out of viewport tracking
  • TypeScript source with .d.ts declarations
  • Vue 3 only (v2.x); for Vue 2 use v1.x

Install

npm install vue-collision

Quick start

main.ts

import { createApp } from 'vue'
import VueCollision from 'vue-collision'
import App from './App.vue'

createApp(App)
  .use(VueCollision, { globalTriggers: ['resize', 'scroll'] })
  .mount('#app')

Component (<script setup>)

<script setup lang="ts">
const onCollide = (e: CustomEvent) => {
  // e.detail is `window` for viewport events
  console.log('in viewport', e.detail)
}
const onLeave = (e: CustomEvent) => {
  console.log('left viewport')
}
const onGroupCollide = (e: CustomEvent<HTMLElement>) => {
  // e.detail is the other element this element collided with
  console.log('collided with', e.detail)
}
</script>

<template>
  <!-- tracks viewport + 'groupA' element collisions -->
  <div
    v-collision="['groupA']"
    @collide="onCollide"
    @non-collide="onLeave"
    @collide-groupA="onGroupCollide"
    @non-collide-groupA="onGroupCollide"
  />

  <!-- viewport only (no custom group) -->
  <div v-collision @collide="onCollide" @non-collide="onLeave" />

  <!-- groupA only, skip viewport tracking -->
  <div
    v-collision.prevent="['groupA']"
    @collide-groupA="onGroupCollide"
  />
</template>

Directive reference

| Syntax | Behaviour | |--------|-----------| | v-collision | Viewport group + IntersectionObserver | | v-collision.prevent | Opt out of viewport group | | v-collision="['g1', 'g2']" | Add to named groups (g1, g2) | | v-collision.prevent="['g1']" | Named groups only, no viewport tracking |

Events

All events are native DOM CustomEvents. Read the collider from event.detail.

| Event | Fires when | event.detail | |-------|-----------|----------------| | collide | Element enters the viewport | window | | non-collide | Element leaves the viewport | window | | collide-<group> | Element overlaps another in the same group | The other HTMLElement | | non-collide-<group> | Element stops overlapping another in the same group | The other HTMLElement |

Plugin options

app.use(VueCollision, {
  // Events that trigger element-group re-checks. Default: ['resize', 'scroll']
  globalTriggers: ['resize', 'scroll'],
})

Migrating from v1 (Vue 2 → Vue 3)

v2.0.0 is a full Vue 3 rewrite. Key breaking changes:

  1. Install — replace Vue.use(...) with app.use(...).

  2. Event delivery — events are now native DOM CustomEvents, not Vue component events. The collider is on event.detail, not the first argument:

    // v1 (Vue 2)
    onCollide(collider) { /* collider was the Vue instance */ }
    
    // v2 (Vue 3)
    onCollide(event) { const collider = event.detail }
  3. Listen with @ on a plain elementv-collision must be placed on a host element (<div>, <section>, etc.) not a component root. If your component exposes its root element, use v-bind="$attrs" to forward the listeners.

  4. Viewport detection — now uses IntersectionObserver instead of requestAnimationFrame polling (lower CPU, fires immediately).

  5. Element-group re-check timing — element-group collision is checked once per frame-request, triggered by mount, updated, and the configured globalTriggers (default: resize, scroll). Pure CSS transforms or animations that move elements without triggering a scroll, resize, or Vue reactive update will not automatically re-check. Add a global trigger event or call window.dispatchEvent(new Event('resize')) to force a re-check if needed.

Development

npm install
npm run typecheck
npm run build
npm test

License

MIT