Coder Social home page Coder Social logo

barrita's Introduction

Barrita

This is a minimalist solution to replace native scrollbars. No more "big features" will be added, so, if this don't cover your needs, I highly recommend perfect-scrollbar.

Demo

Install

You can choose one of these options:

How to Use it

Basic usage:

$('#scrolleable').barrita(options);

AMD Basic usage:

require('barrita', function(barrita) {
   barrita($('#scrolleable'), options);
});

Manually update scrollbar size on each load image event:

var $scrolleable = $("#scrolleable");
$scrolleable.barrita({resize: 'manual'});
$scrolleable.find('img').on('load', function (e) { 
    $scrolleable.barrita('resize');
});

Listen to positionChange event:

var $scrolleable = $("#scrolleable");
$scrolleable.barrita({hoverTimeout: 0});
$scrolleable.on('barrita:positionChange', function(e, data) {
    console.log(data);
});

For better understanding see index.html source.

Optional parameters

resize

Listen to content/wrapper size changes and adapt scrollbar. I suggest to use 'manual' as value here to improve performance, and then, manually call resize action when you need it (window/wrapper resize, new content, show/hide content, etc). Default: auto

hoverTimeout

Remove 'hover' class from element after x ms than mouseout event was triggered. Use 'false' to avoid this behavior and never hide the scrollbar or 0 to immediately hide it. Default: 500

Events

barrita:init

Params: barrita instance.

barrita:positionChange

Params: Object cointaining: scrollTop (int), onTop (bool) and onBottom (bool) properties.

barrita:destroy

Actions

destroy

Restore original element.

$("#scrolleable").barrita('destroy');

resize

Recalculate bar size.

$("#scrolleable").barrita('resize');

setPosition

Set scrollTop property.

$("#scrolleable").barrita('setPosition', 600);

addContent

Add content to the scrolled element.

$("#scrolleable").barrita('addContent', "<h1>Some title</h1>h1>");

setContent

Empty the scrolled element and sets a new content.

$("#scrolleable").barrita('setContent', "<h1>Some title</h1>h1>");

Dependencies

Required

Optional

  • es5-shim (Only if you want to support IE6/7/8)

TODO

  • Improve personalization options.
  • Better browser compatibility.

Contributing

If you have any suggestion or improve, feel free of make a pull request with your changes or contact me on twitter (@neiker) if you have a great idea but you are too lazy to code it.

Please, respect basic code style guidelines:

  • 4 spaces indentation
  • Use descriptive variable and method names
  • Remove trailing whitespace
  • Use curly braces for single-line control flow statements
  • (try to) respect max cyclomatic complexity
  • Dont't forgot to writte optional semicolons.

Just use grunt jshint to check if you don't break any of these rules. Also, you will find useful grunt build (prod compile) and grunt (dev compile + watch).

About me my english skills

They sucks, I know it.

License

The MIT License (MIT)

Copyright (c) 2014 Javier Alejandro Alvarez [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

barrita's People

Contributors

neiker avatar

Stargazers

Facundo Fernandez avatar Jens Mikkelsen avatar Damián Muti avatar zeph avatar

Watchers

zeph avatar  avatar James Cloos avatar

Forkers

socialmetrix

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.