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

element-in-view-rgermain

v1.4.1

Published

ElementInView is a library that allows to know if an element is displayed in the viewport of the client, it's compatible with overflow parents and offset!

Downloads

6

Readme

header element-in-view is a js library that gives you information if an element is visible or not, it's compatible with elements with a css overflow, and a lot of options !).

Demo

Install npm link

yarn add element-in-view-rgermain
//or
npm install element-in-view-rgermain

Cdn

 <script src="https://unpkg.com/[email protected]/dist/index.js">

If you use with cdn, you can find the library on window.elementInView.

windows.elementInView.all(element, options)
  // or
windows.elementInView.left(element, options)
windows.elementInView.top(element, options)
  //... ect

Usage

// es6 import
import elementInView from "element-in-view-rgermain";
// or es5
const elementInView = require("element-in-view");

const el = document.getElementById("my-element");

if (elementInView.all(el)) {
  console.log("element is visible :D");
} else {
  console.log("element is not visible :(");
}

if (elementInView.right(el)) {
  console.log("right corner of element is visible :D");
} else {
  console.log("right corner of element is not visible :(");
}

/*
    scrollIntoView accept 2 arguments
    first: the element , required !
    seconde: objects for options
*/
const parrentElement = document.getElementById("my-parrent");
elementInView.all(element, {
  parent: parrentElement,
  offsetRight: 50,
  offsetLeft: 10,
  offsetY: -20,
});

API

elementInView.function(element, [options])

function

all

function: elementInView.all()

all corner of element need to be visible

right

function: elementInView.right()

only right corner of element need to be visible

left

function: elementInView.left()

only left corner of element need to be visible

top

function: elementInView.top()

only top corner of element need to be visible

bottom

function: elementInView.bottom()

only bottom corner of element need to be visible

options

Type: Object

partial

Type: Boolean Default: false

 the element must be partly visible 

parent

Type: HtmlElement Default: null

if you define a parent, the element must be in visible only
in relation to this one, that means that if this parent
element is not visible (with an overflow for example)
but that the element is well in the dimensions of this one,
it will return true to you 

offsetX/offsetY

Type: Number Default: 0

a offset for x/y axis

offsetRight / offsetLeft / offsetTop / offsetBottom

Type: Number Default: 0

offset for every axis,
if offsetX is set, we ignore offsetRight and offetLeft
if offsetY is set, we ignore offsetTop and offsetBottom