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

spot.js

v1.1.0

Published

Easily implement mouse event related effects on your website.

Downloads

4

Readme

spot.js

Track mouse position relative to elements in your website. With spot.js, you can:

  • Add the CSS class "spot-perspective" to any element on a website to automatically create a 3D perspective effect with the mouse's position as a focus point.
  • Add the CSS class "spot-shadow" to any element on a website to automatically create dynamic shadows relative to the mouse's position.
  • Add the CSS class "spot-rotate" to any element on a website to automatically rotate an element to face wherever the mouse is.
  • Track mouse angle relative to an element's horizontal axis.
  • Track mouse distance relative to an element's center.
  • Have an easy time developing with on-screen helpers by adding the CSS class "spot-indicator" to any element on a website.
  • Get creative with mouse events using CSS transforms.

Live demos

Click here for a spot.js live demo

Installation

You can download spot.js from this repository or if you use npm:

npm install spot.js

Add spot.js to your HTML document with a script tag:

<script src="spot.js"></script>

And voila! Now you can add the following classes to any element on your website to create different effects:

  • spot-perspective: gives the element a dynamic perspective and 3D rotation effect which changes on mouse move, to simulate the elements "looking at" the mouse cursor. Uses transform: perspective() rotateX() rotateY();
  • spot-shadow: gives the element a dynamic drop-shadow filter which changes on mouse move, to simulate a light coming from your mouse cursor. Uses filter: drop-shadow();
  • spot-rotate: this CSS class rotates the element to face your mouse cursor and updates on mouse move. Uses transform: rotate;
  • spot-indicator: this adds helpful debugging overlays to the selected element. The info shown stands for distance between the mouse cursor and the element's center and the degree (related to the horizontal axis from the center of the element) at which your mouse cursor stands in every instant.
  • spot-area: add this CSS class to any element to restrict where spot.js will listen to mouse move events. If no element has been given this class, the entire window will listen to mouse move events.

Current development goals

  • I'm planning to add many more effects to this library. Feel free to contribute with your own ideas.
  • There are several performance issues that need to be tackled. This is mostly due to the nature of CSS filters but I guess I can also improve my throttling function and probably use requestAnimationFrame(); or something. Suggestions are welcome.
  • The shadow effect doesn't work well together with the rotation effect. They work great separately though.

License

See the LICENSE file for license rights and limitations (MIT).

Feel free to collaborate!