Web端触摸式导航菜单插件—Slideout.js
git地址:
https://github.com/WenryXu/slideout(中文)
https://github.com/Mango/slideout
JS大小:6K
完整demo:
XML/HTML Code复制内容到剪贴板
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Slideout Demo</title>
- <meta http-equiv="cleartype" content="on">
- <meta name="MobileOptimized" content="320">
- <meta name="HandheldFriendly" content="True">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
- <style>
- body {
- width: 100%;
- height: 100%;
- }
- .slideout-menu {
- position: fixed;
- left: 0;
- top: 0;
- bottom: 0;
- right: 0;
- z-index: 0;
- width: 256px;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- display: none;
- }
- .slideout-panel {
- position:relative;
- z-index: 1;
- }
- .slideout-open,
- .slideout-open body,
- .slideout-open .slideout-panel {
- overflow: hidden;
- }
- .slideout-open .slideout-menu {
- display: block;
- }
- </style>
- </head>
- <body>
- <nav id="menu">
- <h2>Menu</h2>
- </nav>
- <main id="panel">
- <header>
- <button class="toggle-button">☰</button>
- <h2>Panel</h2>
- </header>
- </main>
- <script src="dist/slideout.min.js"></script>
- <script>
- var slideout = new Slideout({
- 'panel': document.getElementById('panel'),
- 'menu': document.getElementById('menu'),
- 'padding': 256,
- 'tolerance': 70
- });
- // Toggle button
- document.querySelector('.toggle-button').addEventListener('click', function() {
- slideout.toggle();
- });
- </script>
- </body>
- </html>
上一篇 JQ插件开发demo