html Slideout.js
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html Slideout.js相关的知识,希望对你有一定的参考价值。
<!--
https://github.com/mango/slideout
https://slideout.js.org/
touch slideout navigation menu for your mobile web apps
-->
<!-- -------------------------------------------------
have a menu ("#menu") and a main content ("#panel") into your body.
-->
<nav id="menu">
<header>
<h2>Menu</h2>
</header>
</nav>
<main id="panel">
<header>
<button class="toggle-button">☰</button>
<h2>Panel</h2>
</header>
</main>
<!---------------------------------------------------
CSS
-->
<style>
body {
width: 100%;
height: 100%;
}
.slideout-menu {
position: fixed;
top: 0;
bottom: 0;
width: 256px;
min-height: 100vh;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
z-index: 0;
display: none;
}
.slideout-menu-left {
left: 0;
}
.slideout-menu-right {
right: 0;
}
.slideout-panel {
position: relative;
z-index: 1;
will-change: transform;
background-color: #FFF; /* A background-color is required */
min-height: 100vh;
}
.slideout-open,
.slideout-open body,
.slideout-open .slideout-panel {
overflow: hidden;
}
.slideout-open .slideout-menu {
display: block;
}
/**
enable slideout only on mobile devices: http://codepen.io/pazguille/pen/mEdQvX
*/
@media screen and (min-width: 780px) {
.slideout-panel {
margin-left: 256px;
}
.slideout-menu {
display: block;
}
.btn-hamburger {
display: none;
}
}
</style>
<script src="dist/slideout.min.js"></script>
<script>
//-------------------------------------------------
var slideout = new Slideout({
'panel': document.getElementById('panel'),
'menu': document.getElementById('menu'),
'padding': 256,
'tolerance': 70,
'easing': 'cubic-bezier(.32,2,.55,.27)',
'side': 'right' //open slideout from right side
});
// Toggle button
document.querySelector('.toggle-button').addEventListener('click', function() {
//Toggles (open/close) the slideout menu
slideout.toggle();
});
/**
API
*/
//Opens the slideout menu
slideout.open();
//Closes the slideout menu
slideout.close();
//Returns true if the slideout is currently open
slideout.isOpen(); // true or false
//Cleans up the instance so another slideout can be created on the same area.
slideout.destroy();
//Enables opening the slideout via touch events
slideout.enableTouch();
//Disables opening the slideout via touch events
slideout.disableTouch();
/**
* ## events
*/
slideout.on('open', function() { ... });
slideout.once('open', function() { ... });
slideout.off('open', listener);
slideout.emit('open');
//example
slideout.on('translatestart', function() {
console.log('Start');
});
slideout.on('translate', function(translated) {
console.log('Translate: ' + translated); // 120 in px
});
slideout.on('translateend', function() {
console.log('End');
});
</script>
以上是关于html Slideout.js的主要内容,如果未能解决你的问题,请参考以下文章
Html.Partial 与 Html.RenderPartial 和 Html.Action 与 Html.RenderAction