@atyoursite/classnames

Shared code to use accross our projects

Usage no npm install needed!

<script type="module">
  import atyoursiteClassnames from 'https://cdn.skypack.dev/@atyoursite/classnames';
</script>

README

ClassNames

ElClassName Class

Description

This class is for manipulating classNames

Installation

Open a terminal window inside the root of your project to install the node package.

npm install --save-dev @atyoursite/classnames

Dependency

To be able to use this class, you will have to import it as a dependency

import { ElClassName } from '@atyoursite/classnames';

Instantiate the class

Class parameters

  • el - jQuery element
  • className - Default 'is-hidden'

example

const topNavHide = new elClassName($('#elFixedNavbar'), 'your-class');

Method fromPosition() parameters

  • offset - scrollTop offset to toggle the className

Usage

// Hide and show navigation based on scrolling position and behavior
const topNavHide = new elClassName($('#elFixedNavbar'));
window.addEventListener("scroll", throttle(topNavHide.fromPosition(800), 300));