Giter Site home page Giter Site logo

ngx-scrollspys's Introduction

ngx-scrollspys

This is an extension for Angular 2+ applications, for smooth scroll-spy experience

Installation

Install this extension from npm repository using

  - npm i ngx-scrollspys --save

Setting Up

Setup in your angular project by importing, NeatScrollspyModule into your app.module.ts

      import { NeatScrollspyModule } from 'ngx-scrollspys'; 

      ...... 

      @NgModule({
        declarations: [ ... ],
        imports: [
          ....
          NeatScrollspyModule,
        ]
      })

Getting Started

NeatScrollspy can be used real quick and easy, with just two basics.

  1. Set the point in your HTML you want to monitor scroll

     <div [neatScrollSpy]="{ id: 'uniqueID', selector: 'mains'}">
           // Place code you want to spy on scroll here with assigned selector as class
           // Example <h2 class="mains"></h2>
     </div>
    
  2. Set where to display scroll options and responses

     <neat-scrollspy-template [neatScrollspyOptions]="{ id: 'uniqueID' }"></neat-scrollspy-template>
    

neatScrollSpy (directive)

This is the marker used to tell the extension to listen for elements within its span. The available options for this directive are as follows:

Option Description
id This is a unique field used by the extension template to identify its marker. Note: This field must be unique
selector This is a class field, used by the extension

neat-scrollspy-template (template)

This is the template for neat-scrollspy, which display the scroll options. Available directives within this template are:

highlightOptions (directive)

This option is used for editing the highlighting style of the neatScrollSpy extension. Example of usage:

    <neat-scrollspy-template [highlightOptions]="{ type: 'bold' }" [neatScrollspyOptions]="{ id: 'uniqueID' }"></neat-scrollspy-template>
Option Description
type Uses this option to indicate the type of highlight you want. Available options are: "bold" and "background-color". Default is "bold"
highlightColor This is the color taken by the currently displayed element within view. It is used to indicate which element is currently within view. Default is "blue"
defaultColor This is the default color used by all other elements outside the current view. Default is "black"
highlightTextColor This is the text color used by all elements within the current view. Default is "white"

selectionOrder (directive)

This option is used for editing the number of items highlighted on a page. Example of usage:

    <neat-scrollspy-template [selectionOrder]="{ type: 'first' }" [neatScrollspyOptions]="{ id: 'uniqueID' }"></neat-scrollspy-template>
Option Description
type This is used to indicate which element(s) within view is highlighted. Available options are; "first" and "all". first - This highlights the first element within vie. all - This highlights all element within view

alignOption (directive)

This option is used for editing the alignment structure on the page. Example of usage:

    <neat-scrollspy-template [alignOption]="{ type: 'straight' }" [neatScrollspyOptions]="{ id: 'uniqueID' }"></neat-scrollspy-template>
Option Description
type This is set alignment for the scrollspy options. The Available options are: "straight", "auto", "manual". straight - This aligns all scrollspy options in a straight line (Default). auto - This aligns the scrollspy options in a tree manner, using regular [h1 - h5]. manual - This aligns the scrollspy options as set by the users. Users can set indentation using the "data-align" attribute.
topMargin This accepts an integer as value, indicating the distance from the top of the page to the selected item when clicked

TODO

  • Unit Test
  • Publish Example Page

ngx-scrollspys's People

Contributors

captajo avatar

Watchers

James Cloos 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.