@ianwalter/sled

5.0.0 • Public • Published

@ianwalter/sled

A JavaScript micro-library for animating an element's height to create a slide effect

npm page

About

I created Sled because I wanted to use [Bootstrap's][boostrapUrl] collapsible navbar menu without having to import a bunch of unnecessary code. Sled is 20 lines of code, 182 bytes, and has no dependencies.

Demo

Click here to see the demo.

Installation

npm install @ianwalter/sled --save

Usage

Vanilla JavaScript example:

import Sled from '@ianwalter/sled'
const sled = new Sled(document.querySelector('#myEl'))

// Slide to a specific height:
sled.slide('100px')

// Toggle between 0 height and the elements natural height.
sled.toggle()

Vue.js example:

import Sled from '@ianwalter/sled'

let sled

export default {
  mounted () {
    sled = new Sled(this.$refs.menu)
  },
  methods: {
    toggleMenu: () => sled.toggle()
  }
}

Related

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter

Package Sidebar

Install

npm i @ianwalter/sled

Weekly Downloads

9

Version

5.0.0

License

SEE LICENSE IN LICENSE

Unpacked Size

6.48 kB

Total Files

5

Last publish

Collaborators

  • ianwalter