Reusable JS Utility Helpers that are frequently used by Novicell
Written in pure Vanilla JS, it has no dependencies. It's easy to use with novicell-front end setup (or any es6 compatible build setup).
npm install novicell-helpers
Using tree shaking concept, import the needed function into your JS:
JS
import { helperName } from 'novicell-helpers'
import { toggleClass } from 'novicell-helpers'
const button = document.querySelector('.button');
const siteNavigation = document.querySelector('.navigation');
button.addEventListener('click', function() {
toggleClass(siteNavigation, 'toggle-me');
});
buttonsWithLink();
findAncestor(element, className); // finds ancestor
toggleClass(el, className); // toggles class forth and back
hasClass(element, className); // checks element has class
isVisible(element); // returns a bool depending if element is visible in the viewport
accordionAnimate(element) // Animation of any height closing/opening subelement. Second optional argument is the opening list class, by default it's js-accordion
Looking to contribute something? Here's how you can help. Please take a moment to review our contribution guidelines in order to make the contribution process easy and effective for everyone involved.
The Novicell Frontend is licensed under the MIT license. (http://opensource.org/licenses/MIT)