![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
react-custom-scrollbars
Advanced tools
Readme
npm install react-custom-scrollbars --save
import { Scrollbars } from 'react-custom-scrollbars';
class App extends Component {
render() {
return (
<Scrollbars style={{ width: 500, height: 300 }}>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
</Scrollbars>
);
}
}
Don't forget to set the viewport
meta tag, if you want to support mobile devices
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
import { Scrollbars } from 'react-custom-scrollbars';
class CustomScrollbars extends Component {
render() {
return (
<Scrollbars
className="container"
scrollbarHorizontal={props => <div {...props} className="scrollbar-horizontal" />}
scrollbarVertical={props => <div {...props} className="scrollbar-vertical"/>}
thumbHorizontal={props => <div {...props} className="thumb-horizontal"/>}
thumbVertical={props => <div {...props} className="thumb-vertical"/>}
view={props => <div {...props} className="view"/>}>
{this.props.children}
</Scrollbars>
);
}
}
class App extends Component {
render() {
return (
<CustomScrollbars style={{ width: 500, height: 300 }}>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
<p>Lorem ipsum dolor sit amet, ...</p>
</CustomScrollbars>
);
}
}
<Scrollbars>
onScroll
: (Function) Event handler. Will be called with the native scroll event and some handy values about the current position.
onScroll(event, values)
event
: (Event) Native onScroll eventvalues
: (Object) Values about the current position
values.top
: (Number) scrollTop progess, from 0 to 1values.left
: (Number) scrollLeft progess, from 0 to 1values.clientWidth
: (Number) width of the viewvalues.clientHeight
: (Number) height of the viewvalues.scrollWidth
: (Number) native scrollWidthvalues.scrollHeight
: (Number) native scrollHeightvalues.scrollLeft
: (Number) native scrollLeftvalues.scrollTop
: (Number) native scrollTopscrollbarHorizontal
: (Function) Horizontal scrollbar elementscrollbarVertical
: (Function) Vertical scrollbar elementthumbHorizontal
: (Function) Horizontal thumb elementthumbVertical
: (Function) Vertical thumb elementview
: (Function) The element your content will be rendered inDon't forget to pass the received props to your custom element. Example:
import { Scrollbars } from 'react-custom-scrollbars';
class CustomScrollbars extends Component {
render() {
return (
<Scrollbars
// Set a custom className
scrollbarHorizontal={props => <div {...props} className="scrollbar-vertical"/>}
// Customize inline styles
scrollbarVertical={({ style, ...props}) => {
return <div style={{...style, padding: 20}} {...props}/>;
}}>
{this.props.children}
</Scrollbars>
);
}
}
scrollTop(top)
: Scroll to the top valuescrollLeft(left)
: Scroll to the left valuescrollToTop()
: Scroll to topscrollToBottom()
: Scroll to bottomscrollToLeft()
: Scroll to leftscrollToRight()
: Scroll to rightimport { Scrollbars } from 'react-custom-scrollbars';
class App extends Component {
handleClick() {
this.refs.scrollbars.scrollToTop()
},
render() {
return (
<div>
<Scrollbars
ref="scrollbars"
style={{ width: 500, height: 300 }}>
{/* your content */}
</Scrollbars>
<button onClick={this.handleClick.bind(this)}>
Scroll to top
</button>
</div>
);
}
}
class CustomScrollbars extends Component {
handleScroll(event, values) {
console.log(values);
/*
{
left: 0,
top: 0.21513353115727002
clientWidth: 952
clientHeight: 300
scrollWidth: 952
scrollHeight: 1648
scrollLeft: 0
scrollTop: 290
}
*/
}
render() {
return (
<Scrollbars onScroll={this.handleScroll}>
{this.props.children}
</Scrollbars>
);
}
}
Run the simple example:
cd react-custom-scrollbars/examples/simple
npm install
npm start
MIT
FAQs
React scrollbars component
The npm package react-custom-scrollbars receives a total of 129,576 weekly downloads. As such, react-custom-scrollbars popularity was classified as popular.
We found that react-custom-scrollbars 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.