Git Product home page Git Product logo

fbquicknav.js's Introduction

fbquicknav.js

This vanilla JS plugin creates a quick nav to navigate the sections of a web page.

Take a look at this working demo.

How to use

JS

new FBQuickNav('.jsQuickNav');
const quickNav = new FBQuickNav('.jsQuickNav');
const quickNav = new FBQuickNav('.jsQuickNav', { options });

HTML

QuickNav

Add this in your HTML where you want the quick nav to appear: <div class="quickNav jsQuickNav"></div> (the quickNav class is for CSS styling, and the jsQuickNav is to bind it to the JS).

Sections

For each section that you want in the quick nav:

  • Add the jsQuickNav__section class
  • Add the [data-quicknav-title] data attribute and write in it the title of the section

CSS

The basic styles are in the style.css file. Copy those classes in your project for basic styles.

Dependencies

Options

Configurable options for the plugin. The default values are shown.

new FBQuickNav('.jsQuickNav', {
    
    // Class name of the sections added in the quick nav.
    // Value: CSS selector
    sectionClass: ".jsQuickNav__section",

    // Data attribute for the title of the section, displayed in the quick nav.
    // Value: HTML data attribute
    sectionTitle: "data-quicknav-title",

    // When the quicknav reaches this section, hide it.
    // Value: CSS selector
    sectionClassHide: ".jsQuickNav__hide",
    
    // Offset when scrolling to a section.
    // Value: pixels
    scrollOffset: -100,
    
    // Add a button to open and close the quicknav.
    // Value: boolean
    addTrigger: false,

    // Position of the trigger HTML: before or after the items.
    // Value: boolean
    triggerAfterItems: false,

    // SVG icons of the trigger.
    // Value: SVG
    triggerIconOpen: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 79.53L2.5 32.03l11.56-11.56L50 56.41l35.94-35.94L97.5 32.03z"/></svg>',
    triggerIconClose: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M1.004 89.605l88.6-88.6 9.397 9.397-88.6 88.6z"/><path d="M1.004 10.394L10.402.997l88.6 88.6-9.398 9.397z"/></svg>',

});

fbquicknav.js's People

Contributors

franboud avatar dependabot[bot] 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.