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

@adoratorio/hermes

v1.0.1

Published

A JS utility for scroll events normalization and management

Downloads

76

Readme

Hermes

A utility library for wheel events and touch event normalization

Installation

# Install package
npm install @adoratorio/hermes

Usage

Since this package has a pkg.module field, it’s highly recommended to import it as an ES6 module with some bundlers like webpack or rollup:

import Hermes from '@adoratorio/hermes';
const hermes = new Hermes({ });

If you are not using any bundlers, you can just load the UMD bundle:

<script src="/medusa/umd/index.js"></script>
<script>var medusa = window.Hermes({ });</script>

Available options

Hermes accept in the constructor and option object with the following possible props.

|parameter|type|default|description| |:-------|:--:|:-----:|:----------| |mode|string|Hermes.MODE.VIRTUAL|The mode to use when creating the instance, VIRTUAL will not use any DOM element to detect scroll but mousewheel events instead, FAKE will use a hook div underneath the content to detect scroll and NATIVE will use de DOM element declared as container tod etect scroll events| |events|Array|[Hermes.EVENT.WHEEL, Hermes.EVENT.TOUCH, Hermes.EVENT.KEYS]|The events to listen to| |container|HTMLElement|document.querySelector('.hermes-container')|The DOM element used as container to detect event on| |hook|HTMLElement|document.querySelector('.hermes-hook')|The DOM element used as hook for scroll amount in FAKE mode| |passive|boolean|true|If you want to use passive event listeners| |emitGlobal|boolean|false|If you want to emit global event on the window| |touchClass|string|'.prevent-touch'|The class used to prevent touch| |touchMultiplier|number|2|A multiplier for touch values, less it's going to be slower scroll and require more user action to scroll, more will end up in a fast page scroll with minimum finger move|

APIs

The main core exposes only two methods

hermesInstance.bind(handler : Function); // Will call the function every event trigger
hermesInstance.unbind();

Otherwhise a global event will be emitted (if emitGlobal option is set to true). Event types are

|name|enum|When| |:---|:--:|:---| |hermes-wheel|Hermes.EVENTS.WHEEL|When a type of mouswheel event is detected| |hermes-touch|Herms.EVENTS.TOUCH|When a touchmouve event occurs after a touchstart, triggered also one last time on touchend with the inertia of the finger leaving the screen| |hermes-spacebar|Hermes.EVENTS.SPACEBAR|When spacebar is pressed in to scroll the page| |hermes-arrows|Hermes.EVENTS.ARROWS|When arrows are pressed to scroll the page| |hermes-keys|Hermes.EVENTS.KEY|When any key (spacebar or arrows) is pressed to scroll the page, this is a sum event of the preceding two| |SCROLL|