1.0.1 • Published 5 years ago

fixedscrollnav v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

↕️ fixedScrollNav

ES6 fixed scroll navigation that allows users to navigate between sections with simple and intuitive arrow buttons. Oh and it will work in all browsers 😉💻 (Chrome, Safari, Edge, Firefox and IE11*)

➡️ Demo ⬅️

Demovideo

✨ Feature List

  • Vanilla ES6 🍦
  • simple and intuitive usage
  • flexible (can be used everywhere)
  • supports nested containers
  • smooth scrolling automatically gets polyfilled only if needed
  • lightweight: ~3kb (minified version + 4kb polyfill if needed)
  • can be controlled via keyboard (A11y ready)

🏗️ Setup

ManagerCommand
yarn (recommended)yarn add fixedscrollnav
npmnpm install fixedscrollnav

👩‍💻 usage

HTML / Markup

use data-fixedScrollNav-section (this marks the beginning of a section) to indicate which sections to scroll to.

<section data-fixedScrollNav-section>
 [...]
</section>
<section data-fixedScrollNav-section>
 [...]
</section>

AND

add the basic navigation markup to html body (best at top/end)

<div class="fixedScrollNav__container">
 <div class="fixedScrollNav__button fixedScrollNav__button--previous" title="go to previous section"></div>
 <div class="fixedScrollNav__button fixedScrollNav__button--next" title="go to next section"></div>
</div>

Use title to adjust the text that is displayed on hover

JS (ES6 Module)

Import*

import fixedScrollNav from '~fixedScrollNav';

or minified

import fixedScrollNav from '~fixedScrollNav.min';

Initialize

new fixedScrollNav();

(This will first test if the markup for the navigation even exist. If not, it won´t initialize.)

*Note: for IE11 support you will also need to use babel-polyfill.

Available Functions/Vars

give your fixedScrollNav a name like

const awesomeNav = new fixedScrollNav();

to use these features.

namefunction
currentSection_indexreturns an index number (starting with 0) of the currently active section
------
scrollToPreviousSection()if available scrolls to previous (above) section
scrollToNextSection()if available scrolls to next (below) section

functions starting with an underscore (_) are meant to be private.(not be called)

You can find a listing of all functions inside DiverentTools:

in your console window.DiverentTools.fixedScrollNav

Styles

Import

@import '~/fixedScrollNav/lib/css/fixedScrollNav';
or
@import '~fixedScrollNav/lib/css/fixedScrollNav.min';

Classes

used classes (default) feel free to adjust to your needs

//container with buttons
//declares the fixed position
.fixedScrollNav__container 

 //button classes
 .fixedScrollNav__button
 
   //arrow up
   .fixedScrollNav__button--previous
   //arrow down
   .fixedScrollNav__button--next

Module Development (Contribution)

clone this repository git clone https://github.com/diverent2/fixedScrollNav.git

cd ./fixedScrollNav

install modules

ManagerCommand
yarnyarn
npmnpm install

start

change source files, adjust the demo and module behavior.

ManagerCommand
yarnyarn start
npmnpm start

build

Managerdemo (./docs)module (./lib)
yarnyarn build-demoyarn build-module
npmnpm run build-demonpm run build-module

for further reference see ⛳SimplePlate

made with ♥️ by diverent2