Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.
/ power-sled Public archive

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

License

Notifications You must be signed in to change notification settings

ianwalter/power-sled

Repository files navigation

@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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published