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

mouse-html

v1.1.3

Published

πŸ“¦ Simple click and hover functionality right in your html

Downloads

801

Readme

πŸ–± mouse-html

⚑ A simple, lightweight npm package for adding click and hover functionality to your HTML elements. This package allows you to create basic dropdowns or sidebars directly in your HTML without needing to write a single line of JavaScript.

🌍 Installation

Add this script to your HTML:

<script src="https://unpkg.com/[email protected]" type="module" defer></script>

πŸš€ Features

πŸ–± Mouse Click and Hover

Add a mouse-click or mouse-hover attribute to an HTML element:

<button mouse-hover=".box">Show Div</button>

The attribute's value is a document.querySelector() selector that targets the corresponding DOM element:

<button mouse-click=".box">Show Div</button>
<div class="box">Just a div with a class</div>
<button mouse-click="#box">Show Div</button>
<div id="box">Just a div with an ID</div>
<button mouse-click="div">Show Div</button>
<div>Just a div</div>

A .hidden { display: none; } class is automatically added to the element specified in the attribute, making it initially hidden.

✨ Mouse Swap

Add a mouse-swap attribute to an HTML element:

<button mouse-swap=".box">Show Div</button>

This attribute creates a click-to-swap relationship between the element with the attribute and the specified target element:

<button mouse-swap="#box">Click me to hide me and show the div</button>
<div id="box">Click me to hide me and show the button</div>

The element with the mouse-swap attribute is initially visible, while the target element starts off hidden.

πŸŽ‰ Animations

Add a mouse-animation attribute to any element in the DOM:

<div class="box" mouse-animation="fade">Just a div with animation</div>

This adds a CSS animation effect that triggers when the element appears in the DOM. You can apply this attribute to any element or combine it with other attributes. Each animation has its own default timing, which cannot be changed. Available animations include:

  1. fade
  2. X
  3. Y

The X and Y animations also accept an optional mouse-animation-length attribute, where you can set the number of pixels the element travels. This pixel value can be positive or negative:

<button mouse-swap="div">Click me to see the div and hide me</button>
<div mouse-animation="fade">Click me to hide me and see the button again</div>
<button mouse-click=".box">Click me to see the div and hide me</button>
<div class="box" mouse-animation="X" mouse-animation-length="-500">I translate X by -500 pixels</div>

You can also create custom CSS animations:

<div class="box" mouse-animation="spring">Just a div with animation</div>
@keyframes spring {
    0% { transform: scale(1); }
    30% { transform: scale(1.2); }
    50% { transform: scale(0.9); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.spring {
  animation: spring 0.6s cubic-bezier(0.5, 1.5, 0.5, 1) forwards;
}

πŸ”— Links

πŸ“¦ NPM: https://www.npmjs.com/package/mouse-html πŸ±β€πŸ‘€ GitHub: https://github.com/nabeelipynb/mouse-html