'How to set timeScale for only reverse animation GSAP
What I'm trying here is when I toggle the Bootstrap button then reverse animation should go faster already google about timeScale(3); but How can I add timeScale only for reverse animation on toggle script. You can check Example
gsap.set("#sidebar-nav a", { opacity: 0, y: 100 });
var nv = gsap.timeline({ paused: true })
.to("#sidebar-nav a:nth-child(1)", { duration: 0.2, delay: 0.3, opacity: 1, y: 0 })
.to("#sidebar-nav a:nth-child(2)", { duration: 0.2, opacity: 1, y: 0 })
.to("#sidebar-nav a:nth-child(3)", { duration: 0.2, opacity: 1, y: 0 })
.reverse();
var buttOn = document.querySelector(".toggle-btn");
buttOn.addEventListener("click", function() {
nv.reversed(!nv.reversed());
});
@import url("https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css");
#sidebar-nav {
width: 160px;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<div class="container-fluid">
<div class="row flex-nowrap">
<div class="col-auto px-0">
<div id="sidebar" class="collapse collapse-horizontal border-end">
<div id="sidebar-nav" class="list-group border-0 rounded-0 text-sm-start min-vh-100">
<a href="#" class="list-group-item border-end-0 d-inline-block text-truncate" data-bs-parent="#sidebar"><i class="bi bi-bootstrap"></i> <span>Item</span> </a>
<a href="#" class="list-group-item border-end-0 d-inline-block text-truncate" data-bs-parent="#sidebar"><i class="bi bi-film"></i> <span>Item</span></a>
<a href="#" class="list-group-item border-end-0 d-inline-block text-truncate" data-bs-parent="#sidebar"><i class="bi bi-heart"></i> <span>Item</span></a>
</div>
</div>
</div>
<main class="col ps-md-2 pt-2">
<a href="#" data-bs-target="#sidebar" data-bs-toggle="collapse" class="toggle-btn border rounded-3 p-1 text-decoration-none"><i class="bi bi-list bi-lg py-2 p-1"></i> Menu</a>
<div class="page-header pt-3">
<h2>Bootstrap 5 Sidebar Menu - Simple</h2>
</div>
<p class="lead">A offcanvas "push" vertical nav menu example.</p>
<hr>
<div class="row">
<div class="col-12">
<p>This is a simple collapsing sidebar menu for Bootstrap 5. Unlike the Offcanvas component that overlays the content, this sidebar will "push" the content. Sriracha biodiesel taxidermy organic post-ironic, Intelligentsia salvia mustache 90's code editing brunch. Butcher polaroid VHS art party, hashtag Brooklyn deep v PBR narwhal sustainable mixtape swag wolf squid tote bag. Tote bag cronut semiotics, raw denim deep v taxidermy messenger bag. Tofu YOLO Etsy, direct trade ethical Odd Future jean shorts paleo. Forage Shoreditch tousled aesthetic irony, street art organic Bushwick artisan cliche semiotics ugh synth chillwave meditation. Shabby chic lomo plaid vinyl chambray Vice. Vice sustainable cardigan, Williamsburg master cleanse hella DIY 90's blog.</p>
<p>Ethical Kickstarter PBR asymmetrical lo-fi. Dreamcatcher street art Carles, stumptown gluten-free Kickstarter artisan Wes Anderson wolf pug. Godard sustainable you probably haven't heard of them, vegan farm-to-table Williamsburg slow-carb readymade disrupt deep v. Meggings seitan Wes Anderson semiotics, cliche American Apparel whatever. Helvetica cray plaid, vegan brunch Banksy leggings +1 direct trade. Wayfarers codeply PBR selfies. Banh mi McSweeney's Shoreditch selfies, forage fingerstache food truck occupy YOLO Pitchfork fixie iPhone fanny pack art party Portland.</p>
</div>
</div>
</main>
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
