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

kissui.position

v0.5.0

Published

Track element(s) on the page like a boss.

Downloads

11

Readme

kissui.position

Track element(s) on the page like a boss.

This library is a part of Kissui project.

Install

You can use NPM or Bower or download the package manually.

Getting Started

Using this libarary is as easy as adding data-kui-position attribute to your elements:

<p data-kui-position="in"></p>

and then bind an event listener:

kissuiPosition.on ('in', function (element) {
  console.log('yay!', element);
});

and to init the library, call this before </body>:

kissuiPosition.init();

That's it.

Events

Here is a list of available events:

  • in - when element is in the viewport
  • out - when element is not in the viewport
  • middle - center aligned element (vertically)
  • center - center aligned element (horizontally)
  • top - element at the top of the page
  • bottom - elemennt at the bottom of the page
  • left - element at the left side of the page
  • right - element at the right side of the page
  • partially - with one only works with out event, e.g. partially out and it means when the element is partially out of the element (e.g. half of the height or width)

Also, it is possible to use a compond of events together.

Example:

Element is in the viewport and center of the page:

<p data-kui-position="in center"></p>

Element is located in the center and middle of the page:

<p data-kui-position="in middle center"></p>

EventListener

It is possible to listen to events and catch them using following methods.

ID-based event

You can get the events of an element using its ID. Let's say you have:

<p id="paragraph" data-kui-position="in right">This element is tracking by Kissui.Position</p>

then you can get events using:

kissuiPosition.on('paragraph', function (element) {
  console.log('with id', element);
});

* event

If you want to get all events, simply bind a callback function to * event:

kissuiPosition.on('*', function (element, event) {
  console.log('*', element, event);
});

position event

Also, you can get all events using its unique data-kui-position attribute value. So, imagine you have:

<p id="paragraph" data-kui-position="in right">this element is tracking by kissui.position</p>

then you can listen to events from in right (with the same order):

kissuiPosition.on('in right', function (element) {
  console.log('single', element);
});

TODOs

  • The combination of out and other events are not completely implemented. now it works with top only, e.g. out top. we should implement other positions as well.
  • Unit testing

What to help? I have a look at the TODO list and send a PR, cheers.

Author

Afshin Mehrabani

License

MIT