Socket
Socket
Sign inDemoInstall

@itkyk/accordion

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @itkyk/accordion

simple accordion logic module


Version published
Weekly downloads
8
decreased by-50%
Maintainers
1
Install size
65.9 kB
Created
Weekly downloads
 

Readme

Source

accordion

install

$ npm i @itkyk/accordion

How to use @itkyk/accordion

<div class="js-accordion">
  <div class="js-accordion-wrap">
    <div class="js-accordion-inner">
      <!--- Your Markup Contents --->
    </div>
  </div>
</div>
import Accordion from "@itkyk/accordion";

// Initialize
const option = {};
const accordion = new Accordion(".js-accordion", option)
/* OR
const accordion = new Accordion(document.querySelector(".js-accordion"), option)
*/
// add callbacks
accordion.setOpenCallback(() => {
  // add function
  console.log("open");
})

accordion.setCloseCallback(()=>{
  // add function
  console.log("close");
})

// start acrodion
accordion.mount();

// desctoy event listener & remove height
accordion.destroy();

Option

keydefaultvaluedescription
type"toggle""toggle""divide"
button".js-accordion-button"string or HTMLElementif type is toggle, open or close torigger className of dom
buttons{open: ".js-accordion-button-open", close: ".js-accordion-button-close"}{open: string or HTMLElement, close: string or HTMLElement}if type is ``, open or close torigger of html elements className of each dom.
wrapper".js-accordion-wrap"string of HTMLElementaccordion wrapper hrml element or className of dom
inner".js-accordion-inner"string of HTMLElementaccordion inner html element or className of dom
initialHeightnullnull or number or className or Elementwhen be closing accordion, set height value. if setting null, .style.height = "";.

methods

keydescription
mountset accordion logics
destroyremove addEventListeners
setOpenCallbackadded function of when opening the accordion
setCloseCallbackadded function of when closing the accordion
getOpenFlagGetting open status. Return Value is true or false

vars

keydescription
targetwhen initialize, set target DOM
buttonwhen initialize, set button DOM or button DOMs
wrapwhen initialize, set wrapper DOM
innerwhen initialize, set inner DOM

Change Log

  • v1.0.6
    • Corrected to remove wrapper height when destroying.
  • v1.0.5
    • Fixed a bug when passing HTMLElement in option.

Keywords

FAQs

Last updated on 05 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc