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

venn-dom

v1.0.0

Published

Utility to detect whether DOM elements are overlapping or not in the viewport

Downloads

3

Readme

venn-dom

Build Status

Utility to detect whether DOM elements are overlapping or not in the viewport

Table of contents

Motivations

After rewriting several approaches to solve this situation in different projects, I decided to put it in a package so I can consume it every time I needed. Really cool for simple web games where you need to check if elements are sharing at least the minimum possible amount of area in the viewport.

Installation

Add it to your application using a package manager.

# npm
npm i venn-dom --save

# yarn
yarn add venn-dom

Usage

Compare two elements

The most simple usage is to compare two elements against each other.

import venn from 'venn-dom'

const base = document.querySelector('.base--element')
const compare = document.querySelector('.compare--element')

venn(base, compare)
// -> Boolean

Compare one element against a collection

You can also pass an array of elements or node list. The library will return an array containing one boolean per each element in the collection, representing the state of interception between the base element with the one from the collection in the same position.

import venn from 'venn-dom'

const base = document.querySelector('.base--element')
const list = document.querySelectorAll('.compare--element')

venn(base, list)
// -> Array

Example from above would also work with Array or HTMLCollection instances.

Contributing

  • Clone or fork this repository.
  • In the root folder, run yarn to install the dependencies.
  • Apply your fixes or features.

Update or add tests if necessary.

  • Run yarn test to make sure there's no regression.
  • Submit a PR 🎉

You can do yarn test --watch when working on TDD mode.

Stuff to do

The library is on early stages, if you want to collaborate, here are some ideas:

  • Add better unit tests mocking client rects.
  • Add linting and precommit hooks.
  • The library is using standard and this format for commits.
  • Run the library on some real scenarios and check out if there are issues to solve.
  • Audit and apply performacne improvements if necessary.
  • Any feature you think is missing ⭐️