Skip to content

Latest commit

 

History

History
337 lines (312 loc) · 16.1 KB

VariablesAbout.md

File metadata and controls

337 lines (312 loc) · 16.1 KB

Internal Variables

The universalsmoothscroll-min.js script will declare and initialize the uss object as a public property of Window.
This object has the below listed properties and they're internally used to control all the API's scroll-animations.
These properties are also mentioned in other sections of the documentation so may find this helpful.

N.B.

Even though it's possible to directly modify these properties it's highly discouraged: the best way to get/set them is through the provided accessors. Manually altering the properties listed below may cause the API to not function properly.
Moreover any one of them can be renamed, deleted and/or repurposed at any time by an update.

Name Type Default value Description
_containersData Map new Map A Map in which:
  • The keys are an instances of Element or the Window and they're internally called containers.
  • The values are arrays.
_xStepLength Number DEFAULT_XSTEP_LENGTH If there's no stepLengthCalculator set for a container, this represent the number of pixel scrolled during a single scroll-animation's step on the x-axis of that container.
_yStepLength Number DEFAULT_YSTEP_LENGTH If there's no stepLengthCalculator set for a container, this represent the number of pixel scrolled during a single scroll-animation's step on the y-axis of that container.
_minAnimationFrame Number DEFAULT_MIN_ANIMATION_FRAMES This represents the lowest number of frames any scroll-animation on a container should last if no stepLengthCalculator is set for it.
_windowWidth Number INITIAL_WINDOW_WIDTH The current Window's inner width (in px).
_windowHeight Number INITIAL_WINDOW_HEIGHT The current Window's inner height (in px).
_scrollbarsMaxDimension Number Depends on the user's browser The highest number of pixels any scrollbar on the page can occupy (it's browser dependent).
_framesTime Number DEFAULT_FRAME_TIME The time in milliseconds between two consecutive browser's frame repaints (e.g. at 60fps this is 16.6ms). It's the average of the values of _framesTimes.
_framesTimes Array [] Contains at most the last 10 calculated frames' times.
_windowScroller Object Depends on the webpage style The element that scrolls the Window when it's scrolled and that (viceversa) is scrolled when the Window is scrolled.
_pageScroller Object Depends on the webpage style The element that scrolls the document.
It's also the value used when an API method requires the container input parameter but nothing is passed.
_reducedMotion Boolean Depends on user's system preference True if the user has enabled any reduce-motion setting devicewise, false otherwise.
Internally used by the API to follow the user's accessibility preferences by reverting back every scroll-animation to the default jump-to-position behavior.
_onResizeEndCallbacks Array [] Contains all the functions that should be executed only once the user has finished resizing the browser's window and has interacted with it.
An interaction can be a:
  • pointerover event
  • pointerdown event
  • touchstart event
  • mousemove event
  • keydown event
  • focus event
_debugMode String "" Controls the way the warning and error messages are logged by the default error/warning loggers.
If it's set to:
  • "disabled" (case insensitive) the API won't show any warning or error message.
  • "legacy" (case insensitive) the API won't style any warning or error message.
  • Any other string will make the warning/error messages be displayed with the default API's styling.
Custom values of the _errorLogger and/or _warningLogger properties should respect this preference.
_errorLogger Function DEFAULT_ERROR_LOGGER Logs the API error messages inside the browser's console.
_warningLogger Function DEFAULT_WARNING_LOGGER Logs the API warning messages inside the browser's console.


The _containersData arrays

The _containersData variable is a Map and its values are arrays.
This is what each array contains:

Index Type Description
0 Number Contains the ID of a requested scroll-animation on the x-axis of this container provided by the requestAnimationFrame method.
It's null or undefined if no scroll-animation on the x-axis of this container is currently being performed.
1 Number Contains the ID of a requested scroll-animation on the y-axis of this container provided by the requestAnimationFrame method.
It's null or undefined if no scroll-animation on the y-axis of this container is currently being performed.
2 Number Contains the final position (in px) at which this container will be at the end of the current scroll-animation on the x-axis.
3 Number Contains the final position (in px) at which this container will be at the end of the current scroll-animation on the y-axis.
4 Number Contains the direction of the current scroll-animation on the x-axis of this container:
1 if the scrolling is from right-to-left, -1 otherwise.
5 Number Contains the direction of the current scroll-animation on the y-axis of this container:
1 if the scrolling is from bottom-to-top, -1 otherwise.
6 Number Contains the total amount of pixels that have to be scrolled by current scroll-animation on the x-axis of this container.
7 Number Contains the total amount of pixels that have to be scrolled by current scroll-animation on the y-axis of this container.
8 Number Contains the starting time in milliseconds (as a DOMHighResTimeStamp) of the current scroll-animation on the x-axis of this container.
It's null if a scroll-animation on the x-axis of this container has been scheduled but has not been performed yet or if a scroll-animation with stillStart = false has been requested.
9 Number Contains the starting time in milliseconds (as a DOMHighResTimeStamp) of the current scroll-animation on the y-axis of this container.
It's null if a scroll-animation on the y-axis of this container has been scheduled but has not been performed yet or if a scroll-animation with stillStart = false has been requested.
10 Function Contains a callback function that will be executed when the current scroll-animation on the x-axis of this container has been performed.
11 Function Contains a callback function that will be executed when the current scroll-animation on the y-axis of this container has been performed.
12 Function Contains the stepLengthCalculator that controls the scroll-animations on the x-axis of this container.
13 Function Contains the stepLengthCalculator that controls the scroll-animations on the y-axis of this container.
14 Function Contains the stepLengthCalculator that controls the scroll-animations on the x-axis of this container.
If valid, replaces 12 for the current scroll-animation on the x-axis of this container and it's automatically invalidated at the end.
15 Function Contains the stepLengthCalculator that controls the scroll-animations on the y-axis of this container.
If valid, replaces 13 for the current scroll-animation on the y-axis of this container and it's automatically invalidated at the end.
16 Number Contains the cached value of the highest reacheable scrollLeft/scrollX value of this container (its maxScrollX).
17 Number Contains the cached value of the highest reacheable scrollTop/scrollY value of this container (its maxScrollY).
18 Number Contains the cached value of the vertical scrollbar's width of this container.
19 Number Contains the cached value of the horizontal scrollbar's height of this container.
20 Number Contains the cached value of the top border's height (in px) of this container.
21 Number Contains the cached value of the right border's width (in px) of this container.
22 Number Contains the cached value of the bottom border's height (in px) of this container.
23 Number Contains the cached value of the left border's width (in px) of this container.
24 Object Contains the cached value of this container's next scrollable parent on the x-axis which does not have overflow-x:hidden.
25 Object Contains the cached value of this container's next scrollable parent on the x-axis which has overflow-x:hidden.
26 Object Contains the cached value of this container's next scrollable parent on the y-axis which does not have overflow-y:hidden.
27 Object Contains the cached value of this container's next scrollable parent on the y-axis which has overflow-y:hidden.
28 Function Contains the cached value of this container's scrollXCalculator.
29 Function Contains the cached value of this container's scrollYCalculator.

This container refers to the key linked to each array.