1.0.1 • Published 6 months ago

@adoratorio/hermes v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 months ago

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.

parametertypedefaultdescription
modestringHermes.MODE.VIRTUALThe 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
eventsArray[Hermes.EVENT.WHEEL, Hermes.EVENT.TOUCH, Hermes.EVENT.KEYS]The events to listen to
containerHTMLElementdocument.querySelector('.hermes-container')The DOM element used as container to detect event on
hookHTMLElementdocument.querySelector('.hermes-hook')The DOM element used as hook for scroll amount in FAKE mode
passivebooleantrueIf you want to use passive event listeners
emitGlobalbooleanfalseIf you want to emit global event on the window
touchClassstring'.prevent-touch'The class used to prevent touch
touchMultipliernumber2A 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

nameenumWhen
hermes-wheelHermes.EVENTS.WHEELWhen a type of mouswheel event is detected
hermes-touchHerms.EVENTS.TOUCHWhen a touchmouve event occurs after a touchstart, triggered also one last time on touchend with the inertia of the finger leaving the screen
hermes-spacebarHermes.EVENTS.SPACEBARWhen spacebar is pressed in to scroll the page
hermes-arrowsHermes.EVENTS.ARROWSWhen arrows are pressed to scroll the page
hermes-keysHermes.EVENTS.KEYWhen any key (spacebar or arrows) is pressed to scroll the page, this is a sum event of the preceding two
SCROLL
1.0.1

6 months ago

1.0.0

1 year ago

0.1.35

2 years ago

0.1.34

4 years ago

0.1.33

4 years ago

0.1.31

4 years ago

0.1.32

4 years ago

0.1.30

4 years ago

0.1.29

4 years ago

0.1.27

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago