Swibe
A simple slide menu in JS
Getting started
-
Install the npm package:
npm install swibe -
Add the basic markup
MenuItemItemItemItem -
Import Swibe in your code, create a new instance and initialize it.
;const menu = {};menu;
You can instead load it into the HTML.
<!-- Downloaded file --><script src="swibe.min.js"></script> <!-- With UNPKG --><script src="https://unpkg.com/swibe"></script>
You can see a basic working demo in /docs/index.html
API
init()
: Initialize your Swibe instanceopen()
: Open the menuclose()
: Close the menutoggle()
: Toggle the menu
Options
; const menu = transition: '200ms' breakpoint: '960px' enableCallback: moveMainNav disableCallback: restoreMainNav; menu;
menuID: 'swibe-menu'
| The menu IDtriggerID: 'swibe-menu-trigger'
| The trigger IDwidth: '300px'
| The menu widthtransition: '300ms'
| Transition time to open and close the menushadowOpacity: 0.5
| Shadow background opacityzIndex: 999
| Menu z-index property.breakpoint: undefined
| The breakpoint where menu enable or disable. (Else, is enabled everytime)disableCallback: undefined
| Function that run every time that menu is disabled. (Only works if you use a breakpoint)enableCallback: undefined
| Function that run every time that menu is enabled. (If don't use a breakpoint, only works one time at init)openCallback: undefined
| Function that run every time that menu is openedcloseCallback: undefined
| Function that run every time that menu is closed
Changelog
See Releases.
Credits
Developed by Iván Barcia
Project tested on BrowserStack
License
This project is under MIT License