All Projects → BosNaufal → React Scrollbar

BosNaufal / React Scrollbar

Licence: mit
The Simplest Scroll Area Component with custom scrollbar for React JS. https://bosnaufal.github.io/react-scrollbar

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Scrollbar

ng-scrollable
Superamazing scrollbars for AngularJS
Stars: ✭ 58 (-4.92%)
Mutual labels:  scrollbar
Ngx Scrollbar
Custom overlay-scrollbars with native scrolling mechanism
Stars: ✭ 355 (+481.97%)
Mutual labels:  scrollbar
Vuebar
(🗃️ Archived) Vue 2 directive for custom scrollbar that uses native scroll behavior. Lightweight, performant, customizable and without dependencies. Used successfully in production on https://ggather.com
Stars: ✭ 650 (+965.57%)
Mutual labels:  scrollbar
custom-scrollbars
ScrollBars customization tool
Stars: ✭ 20 (-67.21%)
Mutual labels:  scrollbar
Fakescroll
vanilla-js lightweight custom HTML scrollbar
Stars: ✭ 309 (+406.56%)
Mutual labels:  scrollbar
Minimap.vim
📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
Stars: ✭ 404 (+562.3%)
Mutual labels:  scrollbar
scrollbar-width
Lightweight tool to get browser's scrollbars width of any browser.
Stars: ✭ 25 (-59.02%)
Mutual labels:  scrollbar
Vuescroll
A customizable scrollbar plugin based on vue.js for PC , mobile phone, touch screen, laptop.
Stars: ✭ 1,016 (+1565.57%)
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 (+437.7%)
Mutual labels:  scrollbar
React Scrollbars Custom
The best React custom scrollbars component
Stars: ✭ 576 (+844.26%)
Mutual labels:  scrollbar
vue-custom-scrollbar
Minimalistic but perfect custom scrollbar component for Vue.JS
Stars: ✭ 95 (+55.74%)
Mutual labels:  scrollbar
Transformerslayout
🔥 App金刚区导航菜单,类似淘宝、QQ音乐等APP导航,方格布局横向多行滑动翻页带滚动条
Stars: ✭ 258 (+322.95%)
Mutual labels:  scrollbar
Reactscrollbar
Scrollbar component for React
Stars: ✭ 450 (+637.7%)
Mutual labels:  scrollbar
vim-sclow
👾 Text-based scrollbar for Vim
Stars: ✭ 23 (-62.3%)
Mutual labels:  scrollbar
Materialscrollbar
An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Stars: ✭ 761 (+1147.54%)
Mutual labels:  scrollbar
Fluent-Design
Microsoft's Fluent Design with pure HTML/CSS/JS
Stars: ✭ 36 (-40.98%)
Mutual labels:  scrollbar
Marquee
跑马灯/滚动文字条(类似于淘宝/菜鸟/京东/支付宝/聚划算/网商银行等app的跑马灯功能)
Stars: ✭ 389 (+537.7%)
Mutual labels:  scrollbar
Vim Scrollstatus
A Vim plugin to display a scrollbar in the statusline
Stars: ✭ 46 (-24.59%)
Mutual labels:  scrollbar
Ember Perfect Scroll
Perfect scroll component as an Ember cli addon
Stars: ✭ 21 (-65.57%)
Mutual labels:  scrollbar
Smooth Scrolling
smooth scrolling and parallax effects on scroll
Stars: ✭ 514 (+742.62%)
Mutual labels:  scrollbar

React Scrollbar

The Simplest Scroll Area Component with custom scrollbar for React Js. It's adopted from reactScrollbar but without any dependencies. All animation, Height and Width are pure CSS, So it's TOTALLY CUSTOMIZABLE and RESPONSIVE! YEAH!.

DEMO

Install

You can install it via NPM

npm install react-scrollbar-js --save

Note: You don't need any other dependencies or webpack loaders to start using this package. You can even use it with the ES5 sintax if you need. But all examples in this readme will be shown in the ES6 sintax.

Usage

// scrollable-component.jsx:
import React from 'react';
import ReactDOM from 'react-dom';

import ReactScrollbar from 'react-scrollbar-js';

class ScrollableComponent extends React.Component {

  render() {
    const myScrollbar = {
      width: 400,
      height: 400,
    };
    return(
      <ReactScrollbar style={myScrollbar}>
        <div className="should-have-a-children scroll-me">
          <p>And Now</p>
          <p>You Can Put</p>
          <p>A Long Content Here</p>
        </div>
      </ReactScrollbar>
    )
  }

}

Note: react-scrollbar-js ships with a good looking default appearance, so you don't need to add any css styles to start it working. Only you need is to pass dimensions via css or inline style. But you can simply customize it by importing your own css styles.

Props

className (String) [optional]

Just the ordinary class name of the root scrollbar element (div). So, It's TOTALLY CUSTOMIZABLE!

default value: 'react-scrollbar-default'

You can set different class names in oder to have some scrollbars with a various appearance on same page.

/*The Scrollbar Root*/
.react-scrollbar-default {
  width: 35%;
  min-width: 300px;
  max-height: 450px;
}

/*The Content*/
.scroll-me {
  min-width: 750px;
}
style (Object) [optional]

If you prefer to use inline style to styling the scrollbar root (div element), you can pass the styling object to this props.

default value: { }

let styling = {

  /* Scrollbar */
  scrollbar: {
    width: "35%",
    minWidth: "300px",
    maxHeight: "450px"
  },

}

<ReactScrollbar style={ styling.scrollbar } />
speed (Number) [optional]

The wheel step in pixel.

default value: 53

API

scrollToY(y), scrollToX(x)

To scroll the scrollbar by vertical/horizontal

where x and y could be:

  • numbers - sets scrollbar position in pixels
  • strings like '58%' - sets scrollbar position in percents

if the value is negative it'll count from the end in the backward direction. ex:

  • scrollToY(150) set vertical scroll to 150px from top
  • scrollToY(-150) set vertical scroll to 150px from bottom
  • scrollToY('30%') set vertical scroll to 30% from top
  • scrollToY('-30%') same as scrollToY('70%')

if you pass the value that is bigger than the maximum size it will scroll to 100%.

// in ScrollableComponent class:
scrollTo(pos) {
  return () => {
    this.scroll.scrollToY(pos);
// or:    this.scroll.scrollToX(pos);
  };
}

// in ScrollableComponent render():
...
<ReactScrollbar ref={(c) => { this.scroll = c; }}>
...

Customizing the appearance

You can add you own css styles to define the appearence and behavior of scrollbar. Scrollbar has a structure of nested elements wich defined by specific css classes. You need to follow this structure to apply your properties to the right place. Each element has a set of classes (the number is different depending on the current mode). In general it has name like: -reactjs-scrollbar-element:modifier1:modifier2. Modifiers are optional and specify a position or a interaction mode of element. For your convenience the elements has a range of classes with different combinations of modifiers, ex:

-reactjs-scrollbar-track // for any scrollbar track in any state
-reactjs-scrollbar-track:vertical // for the vertical scrollbar track in any state
-reactjs-scrollbar-track:dragging // for any scrollbar track while dragging
-reactjs-scrollbar-track:vertical:dragging // for vertical scrollbar track while dragging
-reactjs-scrollbar-track:vertical:dragging:hover // ...and while mouse is over it

But oder of modifiers does matter, so you can't set -reactjs-scrollbar-track:dragging:vertical

This class structure is inspired by -webkit-scrollbar, but here it's pretty simplified

Scrollbar structure
react-scrollbar-default // The scrollbar root. You can set any className here
    
    -reactjs-scrollbar-area // Scrollbar children and tracks are here
    -reactjs-scrollbar-area:dragging // when it's dragging by mouse
    -reactjs-scrollbar-area:scrolling // when it's scrolling by mouse wheel
    
        scroll-content // it just a child element, you can set any className
        
        -reactjs-scrollbar-track // vertical track
        -reactjs-scrollbar-track:vertical:dragging // you can use one of them or bouth
        
            -reactjs-scrollbar-thumb // thumb on vertical track
            -reactjs-scrollbar-thumb:vertical:dragging // you can use one of them or bouth
            
        -reactjs-scrollbar-track // horizontal track
        -reactjs-scrollbar-track:horizontal:dragging // you can use one of them or bouth
        
            -reactjs-scrollbar-thumb // thumb on horizontal track
            -reactjs-scrollbar-thumb:horizontal:dragging // you can use one of them or bouth

You can add :hover or any pseudo class you need.

Style Applying

In oder to set custom style for your scrollbar add css styles to your page.

// scrollable-component.jsx:
import './style_custom1.css';

// ScrollableComponent class:
...
<ReactScrollbar />
...
// style_custom1.css:
.react-scrollbar-default .-reactjs-scrollbar-thumb {
  background: red;
  cursor: default;
  width: 10px;
  height: 10px; 
}

You can have some scrollbars with a different appearance. You can scope it by setting different root class names for them.

You can use the default style as a starting point for customizing:

style_default.css

style_default.scss

Examples

This repo has some example projects.

git clone https://github.com/BosNaufal/react-scrollbar.git
cd react-scrollbar-js/doc/examples/simple
# or 
cd react-scrollbar-js/doc/examples/custom

npm i
npm start

open localhost:8080 in your browser.

Simple example whit navigation API

It has scrollbar with default settings and some navigation buttons

simple

Example of customizing scrollbars

It has scrollbars with different css styles.

custom

Contributing

Start from cloning this repo:

git clone https://github.com/BosNaufal/react-scrollbar.git
cd react-scrollbar-js
npm i
npm start

open localhost:8080 in your browser.

You will see a demo app with a scrollbar area. All source code of this package is located in src/ folder and the demo app is in develop/ (it's not included into this package).

We use webpack-dev-server for developing. It starts by npm start. The config file is webpack.dev.config.js.

We publish to NPM a compiled and bundled code, so it could be used in ES5 projects and don't have any dependencies. To prepare a library bundle we use webpack with the webpack.publish.config.js config file.

To publish it to NPM save all src files and type:

npm publish

this script automatically prepare dist folder for publishing and if there are no errors publish it to NPM.

You can check this process without publishing by typing:

npm run prepublish

it'll do the follow:

  • checks src code with ESLint (npm run lint)

  • builds the library package into dist/ folder (npm run build)

  • puts an actual copy of default style into doc/examples (npm run getstyles) you need to push it to GitHub manually after that

We use ESLint for code linting in this project. You can try to fix some common linting issues by typing npm run lintfix. It'll check the code only within src/ folder.

We are welcome any issues or PR's to make this project better!

Thank You for Making this useful~

Let's talk about some projects with me

Just Contact Me At:

License

MIT Copyright (c) 2016 - forever Naufal Rabbani

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].