new ScrollBar(options)
Custom JavaScript ScrollBar for any conatiner
Build a custom ScrollBar according to the given DOM target, inspired from https://github.com/buzinas/simple-scrollbar <3
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The ScrollBar options Properties
|
- Since:
- January 2022
- Source:
Members
(private) _bar :Object
The DOM element that hold the custom scrollbar itself
Type:
- Object
- Source:
(private) _container :Object
The DOM element that will contain the DOM target content, this DOM element hides the default browser scrollbar
Type:
- Object
- Source:
(private) _horizontal :Boolean
Whether the scrollbar should be horizontal or not
Type:
- Boolean
- Source:
(private) _lastPageX :Number
For horizontal scroll, save the last user X position for position computations
Type:
- Number
- Source:
(private) _lastPageY :Number
For vertical scroll, save the last user Y position for position computations
Type:
- Number
- Source:
(private) _minSize :Number
The minimal size in pixels for scrollbar to be
Type:
- Number
- Source:
(private) _scrollRatio :Number
Ratio between DOM target and content size, if < 1, it requires a scrollbar
Type:
- Number
- Source:
(private) _style :Object
Optionnal custom style object. Support for color, size, radius, lowOpacity, highOpacity and transitionDuration
Type:
- Object
- Source:
(private) _target :Object
The DOM target element to put a scrollbar on
Type:
- Object
- Source:
(private) _wrapper :Object
The DOM element that will wrap the DOM target content
Type:
- Object
- Source:
style
Updates the scrollbar style. Support for color, size, radius, lowOpacity, highOpacity and transitionDuration
- Source:
Methods
(private, static) _barClicked(event)
Add document events when bar is clicked to track the mouse movement in parent
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | The Mouse event from this._events() |
- Since:
- January 2022
- Source:
(private, static) _drag(event)
Handle the drag animation of the bar
Parameters:
Name | Type | Description |
---|---|---|
event |
Object | The Mouse event from this._events() |
- Since:
- January 2022
- Source:
(private, static) _events() → {Promise}
Handle ScrollBar mouse events
- Since:
- January 2022
- Source:
Returns:
A Js promise resolved when all events are registered
- Type
- Promise
(private, static) _init() → {Promise}
Build DOM hierrarchy, ScrollBar double wraps the content to append its custom bar
- Since:
- January 2022
- Source:
Returns:
A Js promise resolved when DOM is fully initialized
- Type
- Promise
(private, static) _stopDrag()
Remove document events when bar is released
- Since:
- January 2022
- Source:
(private, static) _updateScrollBar()
Compute bar position according to DOM measurements
- Since:
- January 2022
- Source:
(static) updateScrollbar()
Manually update the scrollbar
- Since:
- January 2022
- Source: