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

magneteffect

v1.0.6

Published

Magnet Effect

Downloads

2

Readme

Magnet Effect

JavaScript and React package, that provides a special magnet effect when closing in on items.


Installation

npm install magneteffect

Usage

The package has 3 different exports, Direction, Mouse, and MagnetEffect.

Direction

import { Direction } from "magneteffect";

// Call for class
const direction = new Direction();

window.addEventListener("mousemove", (e) => {
  // Set Direction
  direction.calculateDirectionX(e.screenX);
  direction.calculateDirectionY(e.screenY);

  // Will log direction
  console.log(direction.directionX, direction.directionY);
});

Mouse

The mouse class has a total of 1 parameter, which is the className of the elements you want to apply a mouse hover effect on. If no className is given the mouse won't make a hover effect.

import { Mouse } from "magneteffect";

// Call for class
const mouse = new Mouse("item"); // Provide className (parameter)

// Element
<div class="item">I'm an element!</div>;

MagnetEffect

The magnet effect works on multiple items which you can provide through a loop. The magnetEffect class takes in two parameters which are (element, boolean).

The element: This is the element you want to have the magneteffect (provide a single element). The boolean: The boolean when true makes the element when having been applied the magnetEffect spring back to its original place. If false the element can be used as a draggable item.

Note: Do not use the magnetEffect on elements DIRECTLY under a section element, this can disrupt the elements.

import { MagnetEffect } from "magneteffect";

// Loop over all the items you want the magnet effect to be applied too.
document.querySelectorAll(".magnetItem").forEach((e) => {
  // Two paramaters - Explained up above.
  new MagnetEffect(e, true);
});

Here is the source-code if you're interested: Magnet Effect Github;