@roghz/slidetoggle

1.0.4 • Public • Published

slideToggle()

Small script for VanillaJS slideToggle.

USAGE

Install package by npm

npm i @roghz/slidetoggle

Install package by yarn

yarn add @roghz/slidetoggle

Usage Example

import { slideToggle } from '@roghz/slidetoggle';
//import { slideUp, slideDown, slideToggle } from '@roghz/slidetoggle';

const accordionsBlock = document.querySelectorAll('.accordions');
accordionsBlock.forEach(item => {
    const question = item.querySelectorAll('.accordions__item--heading');
    question.forEach(el => {
        el.addEventListener('click', () => {
            el.classList.toggle('active');
            slideToggle(el.nextElementSibling, 500, 'flex');
        });
    });
});

//slideToggle(el.nextElementSibling, 500) or slideToggle(el.nextElementSibling, 500, 'displayMode');

LICENSE

MIT License

Package Sidebar

Install

npm i @roghz/slidetoggle

Weekly Downloads

3

Version

1.0.4

License

ISC

Unpacked Size

3.89 kB

Total Files

3

Last publish

Collaborators

  • roghz