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

quicktap

v4.1.0

Published

An :active replacement that doesn't delay on mobile

Downloads

60

Readme

quicktap

quicktap

quicktap implements a class-based replacement for the :active pseudo-class that doesn't delay on mobile. Elements using quicktap should manifest a noticeable improvement in touch latency.

View the demo page on a mobile device, or watch a video of the differences.

Background

You may notice from the demo page how the regular take longer to respond to presses on the mobile device than the quicktap buttons.

Both Chrome and Firefox have a delay between the touchstart event and setting the :active pseudoclass. It is assumed that this is the case to prevent panning or scrolling from causing unintended visual feedback. Unfortunately this sacrifices touch latency even when the user wants to tap on an element.

quicktap gets around this by listening for touchstart and touchend events (among others), and toggling an element's class accordingly. This noticeably improves the user experience, since there is almost instant feedback from a user interaction.

Installation

$ npm install -S quicktap

Usage

const quicktap = require(`quicktap`);

// or using ES modules
import quicktap from 'quicktap';

Apply quicktap enhancements to your chosen element.

quicktap(`#target-element`);

Now, the element will have the .active class when it is pressed.

#target-element {
	background: white;
	color: blue;
}

#target-element.active {
	background: blue;
	color: white;
}

API

quicktap(elOrEls, options={})

Applies quicktap enhancements to elOrEls. This will cause each targeted element to fire an activate event when pressed and a deactivate event when released.

options is an object with two optional properties:

  • class (string): string to use for active class name instead of 'active'
  • context (one of Document, DocumentFragment, HTMLElement): context to use if elOrEls is a selector string. Useful for shadow roots (default: document)

elOrEls may be one of HTMLElement, string (selector), NodeList (returned by DOM methods such as querySelector, or Array (of HTMLElements).

Returns all of the elements that have been successfully modified.

Example

// single element

const elementReference = document.querySelector(`#target-element`);
quicktap(elementReference);

// events

elementReference.addEventListener(`activate`, () => {
    console.log(`element activated`);
});

elementReference.addEventListener(`deactivate`, () => {
    console.log(`element deactivated`);
});

// selector

quicktap(`.selector`);

// NodeList

const elementReferences = document.querySelectorAll(`.selector`);
quicktap(elementReferences);

// array

const elementArray = [
	document.querySelector(`#a`),
	document.querySelector(`#b`),
	document.querySelector(`#c`),
];

quicktap(elementArray);

// unique class

// #target-element will have the 'unique-class' class when pressed
quicktap(`#target-element`, {class: `unique-class`});

// specified context

const containerOfButtons = document.querySelector(`.buttons-container`);
quicktap(`.button`, {context: containerOfButtons});

// shadow DOM (after element has been templated)

const hostElement = document.querySelector(`#shadow-host`);
quicktap(`#shadow-button`, {context: hostElement.shadowRoot});

quicktap.version

Returns an object specifying quicktap's version with the following structure:

{
	major: <Number>,
	minor: <Number>,
	patch: <Number>,
}

License

MIT (see license.txt)