Giter Club home page Giter Club logo

ng-scrollbar's Introduction

ng-scrollbar

A custom scrollbar written in pure AngularJS.

Works with the mouse and on touch screen.

Tired of using jquery for a stupid scrollbar? well, this directive is just for you.

Usage

  1. Add ng-scrollbar.min.js to you main file (index.html)

you can download this by:

In your web page:

<script src="angular.js"></script>
<script src="dist/ng-scrollbar.min.js"></script>
<link rel="stylesheet" href="dist/ng-scrollbar.min.css" >
  1. Set ngScrollbar as a dependency in your module
var myapp = angular.module('myapp', ['ngScrollbar'])
  1. Add ng-scrollbar directive to the wanted element, example:
<div class="scrollme" ng-scrollbar> .... </div>

Rebuild the scrollbar

In case you need to rebuild the scrollbar, you may tell ng-scrollbar to rebuild it for you by broadcasting an event. It's useful to use this option when the size or visibility of the container is dynamic and during the link phase the size can't be determined.

<div class="scrollme" ng-scrollbar rebuild-on="rebuild:me" > .... </div>
// rebuild the scrollbar
$scope.$broadcast('rebuild:me');

In case you need to rebuild the scrollbar on every window's resize, you may use "rebuild-on-resize" option.

<div class="scrollme" ng-scrollbar rebuild-on-resize > .... </div>

In case you need to stick content to bottom (chat or something) use "bottom" option.

<div class="scrollme" ng-scrollbar bottom > .... </div>

Events and Flags

On rebuilding the scrollbar you can get notified by 2 events

  $scope.$on('scrollbar.show', function(){
    console.log('Scrollbar show');
  });
  $scope.$on('scrollbar.hide', function(){
    console.log('Scrollbar hide');
  });

Or you can use "is-bar-shown" option. It should be read-only

<div class="scrollme" ng-scrollbar is-bar-shown="flag" > .... </div>
<div> Bar shown: {{flag}} </div>

Examples

See the example in the respository.

Bitdeli Badge

ng-scrollbar's People

Contributors

asafdav avatar ulfryk avatar subarroca avatar paranoicsan avatar yaneraz avatar csablons avatar bitdeli-chef avatar felixcheruiyot avatar kennethlynne avatar opherv avatar braincomb 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.