-
-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hello.
I've been trying to animate the opening/closing of sub-items in the navigation. I've got successful in animating the expand, but, I don't know how I should animate the collapse.
Here's what I did to animate the expand:
- In my
src\gatsby-theme-document\components\LeftSidebar\NavItem.js, I wrapped the sub-items inside a<div>withoverflow-y: hiddenlike this:
<div style = {{overflowY: "hidden"}}>
{
hasChildren && !isCollapsed && (
<NavItemChild>
{
item.items.map(child => (
<StyledNavItem key = {child.url}>
<NavItemLink to = {child.url} activeClassName = "is-active">
{child.title}
</NavItemLink>
</StyledNavItem>))
}
</NavItemChild>)
}
</div>- In the same file, I added the following styles to
NavItemChild(theconstin the end of the file):
animation-name: animExpand;
animation-duration: 0.25s;
animation-timing-function: var(--ease-in-out-quad);
position: relative- Lastly, in
src\gatsby-theme-document\styles\global.js, I added the animation:
@keyframes animExpand
{
0%
{
top: -100px;
}
100%
{
top: 0px
}
}So, yeah, this works perfectly while expanding, but, the collapsing is still instant. How can I animate that too?
Here's the demo of what I've done:
Metadata
Metadata
Assignees
Labels
No labels
