2 回答

TA貢獻1773條經驗 獲得超3個贊
這就是我認為你可以做到的。您檢查該類是否已應用并根據此添加動畫。
feather.replace();
$(document).ready(function() {
$(".response_menu_icon").click(function() {
if($(".sidebar1").hasClass("sidebar_menu")){
$(".sidebar1").addClass("animate__slideOutRight");
setTimeout(function(){$(".sidebar1").toggleClass("sidebar_menu");},200);
} else {
$(".sidebar1").removeClass("animate__slideOutRight");
$(".sidebar1").addClass("sidebar_menu");
$(".sidebar1").addClass("animate__slideInRight");
};
//$(".sidebar1").addClass("animate__slideOutRight");
});
//
$(".response_more_icon").click(function() {
$(".area1").toggleClass("area_more");
});
});
動畫播放完畢后,我使用設置的超時時間刪除類。

TA貢獻1982條經驗 獲得超2個贊
您可以使用 jQuery 或 JS 添加您的類,并讓您的 CSS 處理您向新位置的過渡。
例如:
你有一個側邊欄,當點擊一個按鈕打開然后再次點擊關閉。
側邊欄 CSS 將具有側邊欄起點(即位置)。然后你可以為你要添加到你希望元素等的結束位置的其他類設置樣式。
?//starting position is hidden off the screen
#sidebar{
? ? position: absolute;
? ? top: 0px;
? ? left: -250px;
? ? width: 250px;
? ? height: 100vh;
? ? background-color: blue;
? ? transition: ease left .3s;
}
//brings the element into view when opened
#sidebar.toggled{
? left: 250px;
}
然后,您可以根據需要單擊按鈕添加課程。
添加回答
舉報