Giter VIP home page Giter VIP logo

customscrollbar's Introduction

customScrollBar

This plugin aims to create a lightweight custom scrollbar.

Oh no!!! Another scrollbar plugin?

"Why did you...?" is what you're thinking?

Let me explain:

I've seen quite a few plugins that try to replicate the scrolling and the scrollbars, yet I haven't found one that is really lightweight, offers triggers (up-down-arrows) and does NOT use the "mousewheel"-plugin.

Most implementations do not translate the native scrolling but rather use the mousewheel events.

In my opinion this is a bad thing so I created this simple plugin that simply "hides" the original scrollbar and adds a second one to replace it. This way the scrollable div will still scroll natively but pass some actions to the new scrollbar.

Interactions on the scrollbar itself will be translated to the scrollable div.

The scrollbar itself only listens to the scroll event.

Options

  • theme: any theme name (string)
  • events:
    • created
    • scrollstarted
    • scrollended
    • thumbclick
    • destroyed
    • ==>
      • call functions when event occurs
      • access event or ui

Methods

  • destroy
  • init

Events

  • create
  • scrollstart
  • scrollend
  • thumbclick
  • destroy

You can listen to these events:

$('.my-selector').on('create', function(){
    // element has been created
});
$('.my-selector').on('scrollend', function(){
    // scrolling has stopped
});

Usage:

$('.my-selector').customScrollBar();

$('.my-selector').customScrollBar('destroy');

$('.my-selector').customScrollBar({
  theme: 'my-custom-theme',
  created: function(e, ui){
        // ...do something
  },
  scrollstarted: function(e, ui){
    // ...do something
  },
  scrollended: function(e, ui){
    // ...do something
  },
  thumbclicked: function(e, ui){
    // ...do something
  }
});

Examples:

http://pixelass.github.io/customScrollBar/

Alpha

Version 2

This is the 2nd version please look for the v1.x branch if you are looking for the old version. This version has a lot cleaner code and can be minified with the goolge-closure-compiler with ADVANCED_OPTIMIZATIONS.

The elements used for the scrollbars are copied from the '-webkit-' scrollbars

(this allows us to do some very detailed styling):

  • scrollbar
  • scrollbar-button
  • scrollbar-track
  • scrollbar-track-piece
  • scrollbar-thumb

What to expect

  • Vertical scrollbar
  • Horizontal scrollbar
  • multiple instances on one page
  • interactive scrollbar
  • full control of the styling via CSS
  • events for created, scrollstart, scrollend, thumbclick, destroyed
  • optional arrows (click-triggers)
  • destroy method

ToDo

  • add more methods and events
  • write a documetation
  • allow nested scrollbars

customscrollbar's People

Contributors

buggy-implementation avatar pixelass avatar

Watchers

 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.