New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@adoratorio/hades

Package Overview
Dependencies
Maintainers
4
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adoratorio/hades

A smooth scrollbar based on Hermes, scroll down 'till hell

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18
decreased by-53.85%
Maintainers
4
Weekly downloads
 
Created
Source

Hades

A smooth scrollbar with optional native scroll or section implementation for performance boosting

Installation

Hades is written in typescript and available as npm package with the alongside types definitions. So install as always

 npm install --save @adoratorio/hades

Usage

Then it can be required or imported as module

import Hades from '@adoratorio/hades';

Internally Hades is using other Adoratorio packages like Hermes for scroll event handling and normalization and Aion for requestAnimationFrame management so also those packages documentations are worth to check out.

Available options

Hades accepts in the constructor an option object with the following possible props.

Note: all options are used only in virtual mode, except of course for the mode one

parametertypedefaultdescription
aion`Aionnull`null
autoplaybooleantrueAutostart the rendering cycle or not.
modestringHades.MODE.VIRTUALA string indicating the scroll mode you wish to use
It can be virtual, native or fake.
Static enumerators are exposed to help:
Note: Mode fake isn't currently implemented.
viewportHTMLElementdocument.querySelector('.hades-viewport')DOM node used to identify the wrapper for the container.
Usually it's a fixed height Element with overflow: hidden for the virtual mode.
In case of native or fake modes, is the scroll container used to detect scroll events.
containerHTMLElementdocument.querySelector('.hades-container')The node translated when the user scrolls.
lockXbooleantrueLock the x axis when detecting scroll events.
lockYbooleanfalseLock the y axis when detecting scroll events.
sections`booleanstring`false
boundaries{ min: { x: number, y:number },max: { x:number, y:number } }Hades.createBoundaries(xMin, xMax, yMin, yMax)The scroll max and min amount in the x and y axis. An object containing these properties { min: { x: 0, y: 0 }, max: { x: 0, y: 0 } }. A static utility function is exposed as helper to build the object: Hades.createBoundaries(xMin, xMax, yMin, yMax).
loopbooleanfalseIf sections and infiniteScroll are enabled you can create an infinite loop of section that cycle continuously.
Note: Currently implemented only for x-axis ({ lockX: false, lockY: true}).
infiniteScrollbooleanfalseWhether or not the boundaries are taken into account when checking the scroll amount, resulting in an infinite scrolling on all axis.
renderScrollbooleanfkalseWhether or not to apply the actual CSS transform property.
If false the internal amount is kept and exposed for your personal use.
callbacks{ Callback, Callback }{frame: () => {}, scroll: () => {} }The scroll function is called each scroll event.
The frame function is called every rAF after updating style.
emitGlobalbooleanfalseIf you want that the custom-scroll generated internally also emit on global scope (window).
startStopPrecisionnumber4A number to define the precision of the start and stop events.
renderByPixelbooleanfalseUsed if you want to apply integer rounded values to the css transition units. If false, the full value is used, resulting in smoother animations, especially the slowest ones.
This avoids stuttering especially at the end of the animation, but its performance consuming.
durationnumber1000The total duration of the scrolling inertia after the user has stopped scrolling. Expressed in ms.
easingFunctionHades.EASING.LINEARA function used to bend the progress over time to match a curve and create more natural scrolling inertia.
The function is called with a single parameter being the time normalized in relation with the total duration (currentTime / totalDuration) so the value is going from 0 to 1.
Eg. for a linear time function(t) { return t; }. It's always a advised to use a linear-in eased-out timing function to avoid weird visual artifacts when the scroll starts.
Some enumerators are exposed, just for having a bunch of useful functions out of the box.
If you wish BezierEasing from bezier-easing npm package can be used as easing function.
touchMultipliernumber1.5A multiplier for calculating the delta of touches and the speed, passed to Hermes.
Reasonable values are between 0.8 and 3 but it's just a suggestion.
Higher values will increase the feeling of slippery touch effect.
smoothDirectionChangebooleanfalseIf true when the scroll direction change the easing setted is kept to help the transition between one direction and the other to feel more inertia.
On really smooth easing and high durations this can feel a bit awkward.
If false an immediate direction change is applied.

APIs

Static Property

EASING

. Hades.EASING.LINEAR
. Hades.EASING.QUAD
. Hades.EASING.CUBIC
. Hades.EASING.QUART
. Hades.EASING.QUINT

MODE

Hades.MODE.VIRTUAL
Hades.MODE.NATIVE
Hades.MODE.FAKE

DIRECTION

Hades.DIRECTION.UP
Hades.DIRRECTION.DOWN
Hades.DIRECTION.INITIAL

Static Methods

Hades.createBoundaries(xMin, xMax, yMin, yMax)
Hades.createBoundires(xMin: number, xMax: number, yMin: number, yMax: number): Boundaries

Create an object that fits the scrollbar boundaries.

Instance Properties

The Hades instance exposes two main properties:

amount

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current scroll amount, updated frame-by-frame.

velocity

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current scroll speed, updated frame-by-frame.

Instance Getters

direction

• Type number Get the current direction of the scroll.

  • Page moving up is 1
  • Page moving down is -1.

Enumerators are also exposed with Hades.DIRECTION.UP, Hades.DIRECTION.DOWN and an inert enum is exposed Hades.DIRECTION.INITIAL.

virtual

• Type boolean Get true if mode is set to virtual or false if not.

native

• Type boolean Get true if mode is set to native or false if not.

fake

• Type boolean Get true if mode is set to native or false if not.

Instance Setters

easing

• Type object Set the easing object. The object contain two params:

  • the easing mode
  • the easing duration

Use the constructor param for the documentation reference of both params

infiniteScroll

• Type boolean Set if infinite scroll is used or not, use the constructor param for documentation reference.

emitGlobal

• Type boolean Set if global events are emitted or not.

boundaries

• Type Boundaries Set a new boundaries to control the scroll max and min amount in the x and y axis.

touchMultiplier

• Type number Set the touch multiplier passed to Hermes instance.

smoothDirectionChange

• Type boolean Set whether to use smooth direction change or not.

renderScroll

• Type boolean Set if to apply CSS transform or not.

Keywords

FAQs

Package last updated on 01 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc