0
我工作創建簡單的全屏菜單,它的工作很好,但有一個問題,也許用戶點擊按鈕點擊多一個(而不是dblclick)和視頻中的這個問題將出現:
Youtbe video
所以我需要的是刪除類當動畫完成:多次點擊添加類
這裏我的代碼:
$(document).ready(function() {
$('.menu-trigger').click(function (e) {
e.preventDefault();
$('.menu').toggleClass('open');
$('.menu .rectangle').removeClass('visible');
$('.menu .rectangle').delay(100).queue(function() {
$(this).addClass('visible').clearQueue();
});
});
})
html, body{
height:100%;
}
.header{
width:100%;
padding:20px;
position:fixed;
z-index:1000;
}
.header .menu-trigger{
width:40px;
height:40px;
background-color:#eaeaea;
cursor:pointer;
position:absolute;
top:20px;
left:20px;
}
.menu {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-o-transform: translateX(-100%);
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
.menu.open {
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
-webkit-transform: translateX(0);
transform: translateX(0);
}
.menu .rectangle{
width:0;
height:20%;
opacity:0;
background-color:#1b1b1b;
-moz-transition: all .3s ease .1s;
-o-transition: all .3s ease .1s;
-webkit-transition: all .3s ease .1s;
transition: all .3s ease .1s;
}
.menu .rectangle:nth-child(2n){
-moz-transition: all .3s ease .2s;
-o-transition: all .3s ease .2s;
-webkit-transition: all .3s ease .2s;
transition: all .3s ease .2s;
}
.menu .rectangle:nth-child(3n){
-moz-transition: all .3s ease .3s;
-o-transition: all .3s ease .3s;
-webkit-transition: all .3s ease .3s;
transition: all .3s ease .3s;
}
.menu .rectangle:nth-child(4n){
-moz-transition: all .3s ease .4s;
-o-transition: all .3s ease .4s;
-webkit-transition: all .3s ease .4s;
transition: all .3s ease .4s;
}
.menu .rectangle:nth-child(5n){
-moz-transition: all .3s ease .5s;
-o-transition: all .3s ease .5s;
-webkit-transition: all .3s ease .5s;
transition: all .3s ease .5s;
}
.menu.open .rectangle.visible{
width:100%;
height:20%;
opacity:1;
background-color:#1b1b1b;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<header class="header">
<div class="menu-trigger"></div>
</header>
<nav class="menu">
<div class="rectangle"></div>
<div class="rectangle"></div>
<div class="rectangle"></div>
<div class="rectangle"></div>
<div class="rectangle"></div>
</nav>
如何做這個問題在不到一分鐘的時間內就會得到兩個upvotes,只有在看到youtube鏈接和youtube鏈接被破壞的時候,才能理解問題。 – Goose
視頻是私密的。 – Draco18s
我編輯的視頻和它現在的工作謝謝 –