Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

baron

Diokuz152.4k3.0.3

A small, fast and crossbrowser custom scrollbar with native system scroll mechanic.

scrollbar, custom, crossbrowser

readme

Build Status Join the chat at https://gitter.im/Diokuz/baron

You cannot change the world, but you can change a scrollbar!

Baron demo

Baron — a small, fast and crossbrowser custom scrollbar with native system scroll mechanic.

See also react-baron.

Demo

API

Skins

Features

  • Doesn't replace native system scroll mechanic.
  • Customizable scrollbar design with full CSS support.
  • Do not depends on external libraries (since v3).
  • Can be inited on hidden blocks
  • Vertical, horizontal and bidirectional scroll
  • Infinite scroll
  • Nested scrollers

Baron do not hide native scrollbar, just hides it. This guarantees scrolling will work in any browser.

1. Hiding system scrollbar

  • Include baron.js and some css:
<script src="baron.js"></script>
<style>
    ::-webkit-scrollbar { /* for Mac OS X support */
        width: 0;
    }
</style>
  • Initialize baron on your scroller:
baron('.my-scroller');

2. Making your own custom-designed scrollbar

You can do everything you want with CSS of your custom scrollbar. There are some required and recommended css rules (see base css) – do not forget to use them. You can also use predefined skins.

Webpack

Just import baron and use it:

import baron from 'baron';
// or: const baron = require('baron');

baron({ scroller: ... });

Version for development

Note, that baron.js is a development version. It contains additional code and log messages, to make the development process easier.

baron.min.js is a production-ready version: weight less, works a little bit faster.

Nested scrollers

Baron do support nested scrollers. To make scrollers happy, follow the rule:

  • Initialize baron instances from ancestor to descendant scrollers order.

Third World War will not begun if you break that rule, but there may be some bad user-experience with baron-instances updates (when size of one scroller depends on size of another). See /demo source.

Browsers support

Baron uses two old CSS 2.1 technologies: 1) overflow: scroll 2) overflow: hidden.

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo Android browser logo
8+ ✔ 3.6+ ✔ 10+ ✔ 11.5+ ✔ 5.1+ ✔ 4+ ✔

Wanna support ie6 and Opera 9? Try baron@2 version + jQuery. Version 3+ uses classList API and style attribute.

3.0 migration

  1. Make sure you are satisfied with new supported browser list.
  2. Remove $ and event params if any. You also could remove jQuery from your page.
  3. Make sure you have one html node per one initialization: multi-baron not supported.
  4. pull plugin removed, so you cannot use it anymore. But you can add it manually.

2.0 migration

impact param default value changed to scroller for all directions. That impact horizontal scrollbars.

If you use % cross-paddings (padding-left and padding-right for vertical direction) for scroller, it will be buggy in Mac OS X Firefox because of need for extra-padding to support it. Use pixels instead, or make html-container inside scroller.

Also, checkout changelog.

1.0 migration

If you have any problems, just set cssGuru option to true.

Chaining

Horizontal and bidirectional scroll

Plugins

License

MIT.

changelog

3.0.0

  • Webpack is used to build client bundle
  • No multiple instances per initialization allowed (only first html node in the list will be taken)
  • Pull plugin is removed
  • No more jQuery or other external libraries dependencies
  • Supported browser list updated: ie9-, Opera 10 and Firefox 3.5- are not supported now

2.3.0

  • Add webpack example
  • params now can be HTMLElement or jQueryObject
  • Rework npm scripts
  • Add yarn
  • Add editorconfig

2.2.2

2.2.0

  • Add position param

2.1.1

  • Update dist files properly

2.1.0

2.0.2

2.0.1

  • Baron now trows an Error when no jQuery nor params.$ found

2.0.0

  • impact default value now always scroller.
  • Mac OS X Firefox support
  • draggingCls now adds to root, not bar
  • second baron init for same direction now always returns existing instance

1.2.1

1.2.0

  • scrollingCls param now sets on root, not scroller.

1.1.0

  • add rtl param.

1.0.3

  • add -ms-overflow-style: none for non-guru css mode.

1.0.2

1.0.0

  • add cssGuru option for css guru.
  • add default css.
  • remove resizeDebounce param.
  • fix phantom tests.
  • remove pause param.

0.8.0

  • impact param added

0.7.16

  • fixed noParams initialization bug for multiple barons on page

0.7.15

  • fixed module.exports bug (now baron is compatible with react-baron)

0.7.14

  • fixed flexbox bug
  • fixed Opera 12 nested flexbox bug
  • rework of horizontal scroll
  • removed freeze param

0.6.2

  • dispose method added (to free memory and remove event listeners when scroller removed from dom)

0.6.0

core:

  • Plugin system added (alpha version)
  • fixable headers moved to 'fix' plugin
  • 'grunt full' now includes test plugin to build
  • 'u' method renamed to 'update'
  • 0.2s delay for update on resize event removed (use 'pause' param instead)

params change

  • 'bar' default value now 'undefined' (!)
  • '$' param added, default value: window.jQuery
  • 'dom' and 'selector' params removed
  • 'direction' ['v', 'h'] param added, default value: 'v'.
  • 'freeze' param added: size of scroller parent freezes at initialization, if true
  • 'pause' param added: use it on slow hardware to limit event trigger frequency (minimum time delay between two triggers in seconds)
  • all params for fixable headers moved to 'fix' plugin

fix plugin:

  • 'header' param renamed to 'elements'
  • 'hFixCls' param renamed to 'outside'
  • 'hBeforeFixCls' param renamed to 'before'
  • 'hAfterFixCls' param renamed to 'after'
  • 'fixRadius' param renamed to 'radius'
  • 'trackSmartLim' param renamed to 'limiter'

plugins:

  • 'controls' plugin added
  • 'test' plugin added

0.5.0

  • Horizontal scroll support
  • Textarea support
  • Dev build added (with error console messages)

0.4.0

Improvements

  • Grunt task runner for build customization added
  • root var removed (use scroller param instead)
  • barOnCls now applied to scroller, not the bar
  • trackSmartLim param added (if true bottom edge of first header uses as bar top limit)
  • fixRadius param added
  • Variable (tex-dependent) headers heights support added
  • noConflict method added

Bugs

  • Right click drag bug fixed
  • Update method now invalidates bar visibility
  • Margin collapse and positioned elements bug fixed

Misc

  • heightChange custom event renamed to sizeChange
  • container param removed
  • hTopFixCls param renamed to hBeforeFixCls
  • hBottomFixCls param renamed to hAfterFixCls
  • barTop param removed
  • "require()" support added
  • Server-side "usage" handler added