
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
side-panel-menu-thing
Advanced tools
Good option for mobile menus, general content reveals, or whatever else.

https://henrygd.me/side-panel-menu-thing
Touch responsive, easy to implement, fairly lightweight, and MIT licensed. Good option for mobile menus, general content reveals, or whatever else.
dist/side-panel-menu-thing.mjsdist/side-panel-menu-thing.umd.jsdist/side-panel-menu-thing.min.jssrc/side-panel-menu-thing.js$ npm install side-panel-menu-thing
Grab the few lines of CSS from dist/side-panel-menu-thing.css and add to your styles, or import from the package.
import sidePanel from 'side-panel-menu-thing'
// target and content required, others optional
const menu = sidePanel({
// target container (where it's mounted and listens for touch)
target: document.body,
// element mounted in panel (will be removed if it exists in DOM)
content: document.getElementById('content'),
// width of panel
width: 400,
// open / close animation time
duration: 450,
// fixed to screen
fixed: true,
// open on left
left: false,
// whether to open on touch drag
dragOpen: true,
// prevent HTML scrolling when fixed
preventScroll: true,
// custom css class(es) added to wrap element (separate multiple with spaces)
wrapClass: '',
// runs when the menu is opened (as soon as it's visible)
onShow(container) {
console.log('showing', container)
},
// runs when the menu is closed (as soon as it's hidden)
onHide() {
console.log('hidden')
},
})
// options are accessible / changeable afterward
menu.width
// 400
menu.width = 500
// 500
// show the panel
menu.show()
// hide the panel
menu.hide()
// destroy
menu.$destroy()
If you have a fixed menu set to open on drag, but want disable on a specific element, add a data-no-panel attribute to the html.
<div class="slider" data-no-panel>
<div class="slide"></div>
<div class="slide"></div>
</div>
This project uses Svelte internally, so you can save some bytes by importing the source files. This may happen automatically if your project picks up the svelte field in package.json, but to be sure you can use the import statement below.
import sidePanel from 'side-panel-menu-thing/src/side-panel-menu-thing'
If you want a proper standalone component with a slot, let me know.
MIT
FAQs
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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.