Giter Site home page Giter Site logo

shhdharmen / ngx-scrollbar-indicator Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 5.27 MB

This will show an indicator with scrollbar

Home Page: https://shhdharmen.github.io/ngx-scrollbar-indicator/

License: MIT License

JavaScript 3.42% TypeScript 79.02% HTML 8.06% SCSS 9.51%
angular scrollbar indicator library list scroll scrolling scrollview scrollable ngx-scrollbar-indicator

ngx-scrollbar-indicator's Introduction

ngx-scrollbar-indicator

npm package Travis CI Build online demo online demo MIT License

Consider a scenario, where you have 100s of items, sorted alphabetically. Now, when user scrolls through the same, user doesn't know easily which character he/she has arrived, this is where ngx-scrollbar-indicator comes in picture. This will add an indicator to scrollbar, which will show first character of the item in view port.


Table of Contents


Description

  • Consider a scenario, where you have 100s of items, sorted alphabetically. Now, when user scrolls through the same, user doesn't know easily which character he/she has arrived, this is where ngx-scrollbar-indicator comes in picture. This will add an indicator to scrollbar, which will show first character of the item in view port. See screenshot below:

what it does gif

NPM

npm i ngx-scrollbar-indicator
  1. Import NgxScrollbarIndicatorModule in your module
...
import { NgxScrollbarIndicatorModule } from 'ngx-scrollbar-indicator';
...
@NgModule({
  ...
  imports: [
    BrowserModule,
    ...,
    NgxScrollbarIndicatorModule
  ]
})
...
  1. import in style.scss
@import "~ngx-scrollbar-indicator/assets/theme.scss";
  1. In your template, wrap you element, in which you want indicator, like below :
<ngx-scrollbar-indicator #indicatorRef>
  <!-- Your element with *ngFor goes here. Do not forget to add attribute 'indicatorItem', which takes string from which first character will be visible in indicator. -->
</ngx-scrollbar-indicator>
  • API consists of Options, Properties, Methods and Observers.
  • You can give options according to you need and modify the behavior. All options are optional. Below is full list of options :
Option Type Description
enable boolean Enable or disable indicator. Default : true
changeWhen deprecated EChangeWhen (top/visible) When the indicator should change the character? When character has reach top of container or as soon as it becomes visible in container. Default : EChangeWhen.top
containerHeight number height of the container, without this, scrolling won't work. Default : 500
theme ETheme (circular/waterDrop/squareLike) Visual theme of indicator, totally based on scss. Default : ETheme.waterDrop
position deprecated EPosition (auto/top) Position of indicator, whether to show on top or auto. Default : EPosition.auto
showWhen EShowWhen (always/scroll) When to show the indicator, always or onscroll/onhover. Default : EShowWhen.scroll
Name Type Description
all ScrollbarIndicatorItemDirective[] All Items Array
firsts { [x: string]: ScrollbarIndicatorItemDirective } JSON Object with first item of each character
lasts { [x: string]: ScrollbarIndicatorItemDirective } JSON Object with last item of each character
Name Parameters Returns Description
showIndicator - timer, this will help to maintain frequent calls to this function
- duration (default 500), after which indicator will be hidden
Timer, which can be cleared if you are calling this function again within duration. Ideally, you shouldn't call this. This will show the indicator. This will add 'show' class to the indicator. And After duration(default 500), if will remove the same. Calling this won't make any sense if showWhen is set to EShowWhen.always
goToLetter - letter, Character to which viewport should be scrolled
- position (default 'first') Element of that character group, first or last
offsetTop of element or -1 if error Scroll to a specific letter, positioned first of last. Returns the offsetTop if element found, else -1. Works only in Non-IE Browsers.
startCalculation none void Call this only if you are changing options in the run-time. This will calculate arrays and characters, based on options. This is called once after ngAfterContentInit hook.

Once you have imported theme.scss in style.scss, you will hae access to some variables. Be cautios while changing the same:

$indicator-background-color: #2196f3 !default;
$indicator-background-size: 46px !default;
$bubble-font-size: 16px !default;
$bubble-font-weight: 400 !default;
$indicator-font-color: #fff !default;
$indicator-margin-right: 8px !default;
$indicator-container-right: 105% !default;
$indicator-right: 105% !default;
$indicator-square-like-border-radius: 4px !default;
  • This project uses the Angular CLI for building the library.
$ ng build ngx-scrollbar-indicator

or

$ npm run build_lib
  • If you identify any errors in the library, or have an idea for an improvement, please open an issue.

I would like to give few credits, as this is my first Angular Library.

  • Thanks
  • Inspiration : Contacts app in Android.
  • Use semantic-release
  • Compatibilities with dates, like a time line
  • Show custom number of characters in indicator
  • Add example with Angular Material
  • Add more examples with bootstrap

npm package Travis CI Build codecov online demo online demo Downloads MIT License npms score dependencies

ngx-scrollbar-indicator's People

Contributors

dependabot[bot] avatar shhdharmen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

manojown

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.