All Projects → souhe → Reactscrollbar

souhe / Reactscrollbar

Licence: mit
Scrollbar component for React

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Reactscrollbar

scrollpup.js
Minimal beautiful bar to show scroll progress. Pure Javascript Plugin.MIT
Stars: ✭ 83 (-81.56%)
Mutual labels:  scrollbar
ng-scrollable
Superamazing scrollbars for AngularJS
Stars: ✭ 58 (-87.11%)
Mutual labels:  scrollbar
Fakescroll
vanilla-js lightweight custom HTML scrollbar
Stars: ✭ 309 (-31.33%)
Mutual labels:  scrollbar
handy-scroll
Handy dependency-free floating scrollbar widget
Stars: ✭ 15 (-96.67%)
Mutual labels:  scrollbar
scrollbar-width
Lightweight tool to get browser's scrollbars width of any browser.
Stars: ✭ 25 (-94.44%)
Mutual labels:  scrollbar
custom-scrollbars
ScrollBars customization tool
Stars: ✭ 20 (-95.56%)
Mutual labels:  scrollbar
ngx-malihu-scrollbar
Angular 2+ scrollbar customization using Malihu jQuery Custom Scrollbar plugin
Stars: ✭ 59 (-86.89%)
Mutual labels:  scrollbar
Marquee
跑马灯/滚动文字条(类似于淘宝/菜鸟/京东/支付宝/聚划算/网商银行等app的跑马灯功能)
Stars: ✭ 389 (-13.56%)
Mutual labels:  scrollbar
Fluent-Design
Microsoft's Fluent Design with pure HTML/CSS/JS
Stars: ✭ 36 (-92%)
Mutual labels:  scrollbar
Transformerslayout
🔥 App金刚区导航菜单,类似淘宝、QQ音乐等APP导航,方格布局横向多行滑动翻页带滚动条
Stars: ✭ 258 (-42.67%)
Mutual labels:  scrollbar
floating-scroll
Lightweight jQuery plugin providing floating scrollbar functionality
Stars: ✭ 72 (-84%)
Mutual labels:  scrollbar
vue-scrolly
Overlay scrollbar for Vue.js.
Stars: ✭ 24 (-94.67%)
Mutual labels:  scrollbar
vue-custom-scrollbar
Minimalistic but perfect custom scrollbar component for Vue.JS
Stars: ✭ 95 (-78.89%)
Mutual labels:  scrollbar
smooth-vuebar
Vue directive wrapper for smooth-scrollbar
Stars: ✭ 29 (-93.56%)
Mutual labels:  scrollbar
Quantum Nox Firefox Dark Full Theme
These usercontent and userchrome files will give a full themed dark color to Firefox Quantum, menus and dialogs included, as well as the scrollbars. You can also use the JS files to enable multirow tabs and other functions.
Stars: ✭ 328 (-27.11%)
Mutual labels:  scrollbar
scrolly.js
Scrolly: fast vanilla JS scrollbar plugin with React.js Component & jQuery/Zepto/jBone plugin.
Stars: ✭ 18 (-96%)
Mutual labels:  scrollbar
vim-sclow
👾 Text-based scrollbar for Vim
Stars: ✭ 23 (-94.89%)
Mutual labels:  scrollbar
Minimap.vim
📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
Stars: ✭ 404 (-10.22%)
Mutual labels:  scrollbar
Ngx Scrollbar
Custom overlay-scrollbars with native scrolling mechanism
Stars: ✭ 355 (-21.11%)
Mutual labels:  scrollbar
Newschannel
新闻频道栏/滚动栏(网易新闻,新浪新闻,搜狐新闻,今日头条,聚划算,腾讯视频,优酷等类的频道栏),支持小红点标识 && 懒加载 && 缓存 && 排序 && 增删等
Stars: ✭ 256 (-43.11%)
Mutual labels:  scrollbar

build status npm package npm downloads

react-scrollbar

Simple ScrollArea component built for React.

Demo

npm install react-scrollbar --save

React Scrollbar requires React 0.13 or later

Features:

  • built with and for React
  • horizontal and vertical scrollbars
  • touch support
  • scrollbar dragging and clicking
  • smooth scrolling
  • universal app support
  • customizable styles
  • and more...

Usage examples

React 0.14

    var React = require('react');
    var ReactDOM = require('react-dom');
    var ScrollArea = require('react-scrollbar');

    var App = React.createClass({
      render() {
        return (
          <ScrollArea
            speed={0.8}
            className="area"
            contentClassName="content"
            horizontal={false}
            >
            <div>Some long content.</div>
          </ScrollArea>
        );
      }
    });

    ReactDOM.render(<App/>, document.body);

React 0.13

For React 0.13 you need to wrap <ScrollArea> child into a function.

<ScrollArea>
    { () => <div>Some long content. </div> }
</ScrollArea>

Version without boundled css styles

If you prefer including scrollbar without css styles boundled inline to js file it's possible to import package without them. It's useful when you want to make custom css changes in scrollbars without using !important in each line.

    var ScrollArea = require('react-scrollbar/no-css');

Then include scrollArea.css file into your project.

Run the example app

git clone https://github.com/souhe/reactScrollbar.git
cd reactScrollbar
npm install
gulp build-examples
gulp less-examples
gulp watch

then open http://localhost:8003.

Using in universal app

ScrollArea component has now full universal app support. It's only one requirement: you have to use react-scrollbar in no-css version and then include css file into your project manually (see this). It's because of issue in webpack style-loader which is used to bundle css styles into main js file.

API

Props

    <ScrollArea
        speed={Number}
        className={String}
        style={Object}
        contentClassName={String}
        contentStyle={Object}
        horizontal={Boolean}
        horizontalContainerStyle={Object}
        horizontalScrollbarStyle={Object}
        vertical={Boolean}
        verticalContainerStyle={Object}
        verticalScrollbarStyle={Object}
        onScroll={(value) => {}}
        contentWindow={Object}
        ownerDocument={Object}
        smoothScrolling={Boolean}
        minScrollSize={Number}
        swapWheelAxes={Boolean}
        stopScrollPropagation={Boolean}
        focusableTabIndex={Number}
    >

speed

Scroll speed applied to mouse wheel event. Default: 1

onScroll

onScroll(value: Object) event which can notify the parent component when the container scrolls.

  • value: Object - informations about current position
  • value.leftPosition: Number - content left position (distance in pixels from the left side of container)
  • value.topPosition: Number - content top position (distance in pixels from the top of container)
  • value.containerHeight: Number - container height
  • value.containerWidth: Number - container width
  • value.realHeight: Number - real content height
  • value.realWidth: Number - real content width

className

CSS class names added to main scroll area component.

style

Inline styles applied to the main scroll area component.

contentClassName

CSS class names added to element with scroll area content.

contentStyle

Inline styles applied to element with scroll area content.

horizontal

When set to false, horizontal scrollbar will not be available. Default: true

horizontalContainerStyle

Inline styles applied to horizontal scrollbar's container.

horizontalScrollbarStyle

Inline styles applied to horizontal scrollbar.

vertical

When set to false, vertical scrollbar will not be available, regardless of the content height. Default: true

verticalContainerStyle

Inline styles applied to vertical scrollbar's container.

verticalScrollbarStyle

Inline styles applied to vertical scrollbar.

contentWindow

You can override window to make scrollarea works inside iframe. Default: window

ownerDocument

You can override document to make scrollarea works inside iframe. Default: document

smoothScrolling

When set to true, smooth scrolling for both scrollbars is enabled. Default: false

minScrollSize

Using this prop it's possible to set minimal size in px for both scrollbars.

swapWheelAxes

After set to true, mouse wheel event has swapped directions. So normal scrolling moves horizontal scrollbar and scrolling with SHIFT key moves vertical scrollbar. It could be useful for applications with horizontal layout. Default: false

stopScrollPropagation

After set to true, mouse wheel event will not propagate. This option is specifically useful in preventing nested scroll areas from propagating scroll actions to parent scroll areas. Default: false

focusableTabIndex

After set to a number, scrollarea-content is rendered with a tabindex value set to the passed in. This option is specifically useful in allowing the scroll area to be focusable. Default: undefined

Context

In context of each <ScrollArea> child could be injected an object scrollArea contains method:

refresh()

That method allows manual refreshing of the scrollbar.

React 0.14 example using ES6 syntax:

class App extends React.Component {
    render(){
        return (
            <ScrollArea>
                <Content />
            </ScrollArea>
        );
    }
}

class Content extends React.Component {
    render(){
        return (
            <div onClick={this.handleSomeAction.bind(this)}> Some long content </div>
        );
    }

    handleSomeAction(){
        this.context.scrollArea.refresh();
    }
}

Content.contextTypes = {
    scrollArea: React.PropTypes.object
};

scrollTop()

It allows to scroll to the top of ScrollArea component.

scrollBottom()

It allows to scroll to the bottom of ScrollArea component.

scrollYTo(topPosition)

It moves vertical scrollbar. topPosition is a distance between the top of scrollArea container and the top of scrollArea content.

scrollLeft()

It allows to scroll to the left of ScrollArea component.

scrollRight()

It allows to scroll to the right of ScrollArea component.

scrollXTo(leftPosition)

It moves horizontal scrollbar. leftPosition is a distance between left edge of scrollArea container and left edge of scrollArea content.

Change log

Every release is documented on the Github Releases page.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].