/power-sled

A JavaScript micro-library for adding dropdown menu functionality to elements

Primary LanguageJavaScriptOtherNOASSERTION

@ianwalter/power-sled

A JavaScript micro-library for adding dropdown menu functionality to elements

npm page

Installation

yarn add @ianwalter/power-sled

Usage

Vanilla JavaScript example:

import PowerSled from '@ianwalter/power-sled'
const sled = new PowerSled(document.myMenuLink, document.myMenu)

// Add an event listener on the body that calls the toggle method. power-sled
// will figure out if it needs to open, close, or do nothing with the menu when
// called.
document.body.addEventListener('click', sled.toggle())

Vue.js example:

import PowerSled from '@ianwalter/power-sled'

let sled

export default {
  mounted () {
    sled = new PowerSled(this.$refs.menuLink, this.$refs.menu)
    document.body.addEventListener('click', sled.toggle())
  },
  destroyed () {
    document.body.removeEventListener('click', sled.toggle())
  }
}

Related

  • @ianwalter/sled - A JavaScript micro-library for animating an element's height to create a slide effect

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter