
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-scroll-box
Advanced tools
Charged cross-browser and cross-platform scrollable container implementation with no external dependencies but React 0.13+
Note I'm currently working on resct-scroll-box@0.3. It would contain 50+ configurable paramters and would provide fine grained tracking of scrolling events and their causes.
Charged cross-browser and cross-platform scrollable container implementation with no external dependencies but React 0.13+.
Requires classList polyfill to work properly in IE9+.
Tested in FF, Chrome, Safari, iOS Safari, Opera and IE9+.
Any help with improvement of this component would be greatly appreciated.
react-text-input for textarea with customizable scrollbars.ScrollBoxIn most cases you should use ScrollBox to create a scrollable area, but in case you need more control over viewport use GenericScrollBox.
By default, ScrollBox has no decoration and behaves as a regular div container. Specify height for scroll box in your styles, otherwise container would contract to zero height.
var ScrollBox = require('react-scroll-box').ScrollBox; // ES5
import {ScrollBox, ScrollAxes, FastTrack} from 'react-scroll-box'; // ES6
<ScrollBox style={{height: '200px'}} axes={ScrollAxes.Y} fastTrack={FastTrack.PAGING}>
Place any content here.
</ScrollBox>
boolean nativeScrollUse native scrollbars. By default, this flag is set to true on mobile platforms and false on desktops. Paltforms are distinguished by presence of window.orientation.
ScrollAxes axes = ScrollAxes.XYScroll axes which are managed by the scroll box. If scroll axis is not listed then corresponding scroll offset would be constantly equal to 0 and any scrolling requests via API or from UI for that axes would be ignored.
integer hoverProximity = 50Maximum distance in pixels between cursor and scroll track edge when track is considered to be hovered. Useful when you want to have thin scrollbars and increase theit thickness when cursor aproaches them so user don't have to aim precisely. Set to 0 to disable hover proximity detection.
boolean disabled = falseDisable scroll box.
boolean outset = falseDisplay scrollbars outside of scrollable area. Outset scrllbars don't require additional space and don't affect surrounding layout. On mobile devices when native scrollbars are used this property has no effect because scrollbars have zero width and thus don't crop any space from viewport.
integer scrollMinX = 2 scrollMinY = 2Minimum difference in pixels in content and viewport sizes to enable scrolling.
boolean captureKeyboard = trueUse keyboard for scrolling when scroll box viewport or its nested content is focused. Keyboard is not captured for <input type="text"/> and <textarea/> elements placed inside scroll box. PgUp PgDown Home End and arrow keys are captured. You can page-scroll alternate axis with Shift + PgUp and Shift + PgDown shortcuts.
integer keyboardStepX = 30 keyboardStepY = 30Distance in pixels to scroll by when arrow keys are pressed.
integer keyboardScrollDuration = 200Keyboard smooth scrolling animation duration in milliseconds. Set to 0 to disable smooth keyboard scrolling.
FastTrack fastTrack = FastTrack.GOTODefines expected behavior when user clicks on scroll track.
integer fastTrackDuration = 500Animation duration of fast track smooth scroll.
boolean captureHandleDrag = trueAllow user to drag scroll handles. If handle drag is disabled along with enabled fast track then clicking on a handle would cause fast tracking.
boolean captureWheel = trueUse mouse wheel for scrolling. You can scroll alternate axis with Shift key is pressed.
integer wheelStepX = 30 wheelStepY = 30Wheel scrolling distance in pixels. Scroll box heavily relies on native wheel implementation, so this speed can vary a bit depending on browser, platform and scrolling device (trackpad or mouse wheel).
boolean propagateWheelScroll = falsePropagate wheel scroll event to parent if scrolling reached maximum or minimum value.
boolean swapWheelAxes = falseSwap wheel scrolling axes.
integer wheelScrollDuration = 100Wheel smooth scrolling animation duration. Set to 0 to disable smooth wheel scrolling.
string className = "scroll-box--wrapped"Style class name to use.
object styleStyle to apply to root element of scroll box.
function defaultEasing (percent, elapsed, min, max, duration)Easing to use when none is provided.
float percent Scroll percentage in range [0, 1].integer elapsed Number of milliseconds passed since animation began.integer min max Output value range.integer duration Animation duration in milliseconds.function onViewportScroll (genericScrollBox)Scroll event callback.
GenericScrollBox genericScrollBox Reference to GenericScrollBox that is being scrolled.GenericScrollBoxExpects viewport element at its only child. Has all the same attributes as ScrollBox.
var GenericScrollBox = require('react-scroll-box').GenericScrollBox; // ES5
import {GenericScrollBox, ScrollAxes, FastTrack} from 'react-scroll-box'; // ES6
<GenericScrollBox style={{height: '200px'}} axes={ScrollAxes.Y} fastTrack={FastTrack.PAGING}>
<div className="scroll-box__viewport">
Place any content here.
</div>
</GenericScrollBox>
<div class="scroll-box scroll-box--wrapped">
<div class="scroll-box__track scroll-box__track--x">
<div class="scroll-box__handle scroll-box__handle--x"></div>
</div>
<div class="scroll-box__track scroll-box__track--y">
<div class="scroll-box__handle scroll-box__handle--y"></div>
</div>
<div class="scroll-box__viewport">
Place any content here.
</div>
</div>
| Class Name | Description |
|---|---|
scroll-box--wrapped | Causes scroll box to look like an actual scroll box. If omitted, then scrollbox behaves like a simple div element. |
scroll-box--disabled | Scroll box is disabled. By default, hides scrollbars and prevents scrolling. |
scroll-box--native | Display native scroll bars. |
scroll-box--outset | Show scroll bars ouside of scrollable area. |
scroll-box--has-axis-x | Scroll box can be scrolled horizintally if content is wider than viewport. |
scroll-box--has-axis-y | Scroll box can be scrolled vertically if content is taller than viewport. |
scroll-box--show-axis-x | Content is wider than viewport. |
scroll-box--show-axis-y | Content is taller than viewport. |
scroll-box__track--hover | Tack is hovered. |
scroll‑box__track‑‑dragged | Track handle is dragged. |
Modifier .scroll-box--wrapped-on-large-screens would conditionally wrap scroll box on screens larger than 360 px. Content would be scrolled along with page itself on smaller screens.
@media (min-width: 360px) {
.scroll-box--wrapped-on-large-screens {
.scroll-box-wrap();
}
}
HTMLDivElement handleX handleYHandle elements. Both are always available, even if axes exclude one or both of them.
HTMLDivElement trackX trackYTrack elements. Both are always available.
HTMLElement viewportViewport element provided to GenericScrollBox.
integer targetX targetYScroll position in pixels that was last requested.
integer previousX previousYPreviously requested scroll position.
integer scrollX scrollXActual scroll position that user observes. This changes repeatedly during scroll animation, when no animation is in proggress equals to targetX and targetY respectively.
integer scrollMaxX scrollMaxYMaximum values for horizontal and vertical content scroll positions. See MDN window.scrollMaxX for more info.
integer trackMaxX trackMaxYMaximum values for horizontal and vertical track scroll positions. When nativeScroll is set to true these are constanly equal to 0.
boolean exposesX exposesYDoes scroll box require actual presence of horizontal or vertical scroll bars. If set to true, then axis is permitted via props.axes and corresponding scrollMax is greater or equal to scrollMin.
void scrollBy(dx, dy, duration, easing, silent)Scroll by the given amount of pixels.
integer dx = 0 dy = 0 Amount of pixels to scroll by. Positive coordinates will scroll to the right and down the content. Negative values will scroll to the left and up the content. If non-numeric value are provided then corresponding position of scroll bar coordinate is not changed.integer duration = 0 Duration of scrolling animation.function easing = defaultEasing Scroll easing function.boolean silent = false Set to true to prevent invocation of onViewportScroll until requested scrolling is finished. Can be used for synchronization of multiple scroll areas.void scrollTo(x, y, duration, easing, silent)Scroll to arbitrary content position.
integer x = undefined y = undefined Position to scroll to. If non-numeric value are provided then corresponding position of scroll bar coordinate is not changed.integer duration = 0 Duration of scrolling animation.function easing = defaultEasing Scroll easing function.boolean silent = false Set to true to prevent invocation of onViewportScroll until requested scrolling is finished. Can be used for synchronization of multiple scroll areas.The code is available under MIT licence.
FAQs
Charged cross-browser and cross-platform scrollable container implementation with no external dependencies but React 0.13+
The npm package react-scroll-box receives a total of 135 weekly downloads. As such, react-scroll-box popularity was classified as not popular.
We found that react-scroll-box demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.