Coder Social home page Coder Social logo

baron's Introduction

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.

Features

  • Doesn't replace native system scroll mechanic.
  • Customizable scrollbar design with full CSS support.
  • No strong dependencies on jQuery.
  • Can be inited on hidden blocks
  • Vertical, horizontal and bidirectional scroll
  • Infinite scroll
  • Nested scrollers

Baron just hides the system scrollbar, without removing it. This guarantees scrolling will work on any system.

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:
$('.my-scroller').baron();

2. Making your own custom-designed scrollbar

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

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 production-ready: 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
1+ ✔ 1+ ✔ 6+ ✔ 9+ ✔ 5+ ✔ 4+ ✔

overflow: scroll not supported by Opera mini and old versions of Android browser (2-). That means, you cannot make scrollable html-elements for them anyway.

Firefox for Mac OS X now supported.

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.

License

MIT.

baron's People

Contributors

diokuz avatar bayandin avatar mialinx avatar pseidemann avatar alexluke avatar dolbyzerr avatar chrisk12345 avatar glenswift avatar faceleg avatar ndragomirov avatar gitter-badger avatar semenov avatar bezdonas avatar darkwebdev avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.