I'm trying to accomplish the following while using calc()
inside a template string:
<Motion
defaultStyle={{
y: 0,
opacity: 1
}}
style={{
y: spring(this.state.navBarOpen ? 0 : `- calc(3.25em + 0.5vw)`),
opacity: spring(this.state.navBarOpen ? 1 : 0)
}}
>
{style => (
<NavBar
style={{
transform: `translateY(${style.y})`,
opacity: style.opacity
}}
clickedOpenMenu={this.onClickMenuSwitchHandler}
/>
)}
</Motion>
The problem here is that there's a template literal within a template literal and I don't know how to avoid this problem in order to make the animation work.
I need the calc()
in order to actively resize the <NavBar/>
according to the font size and the view port, but I also want the <NavBar/>
to be animated by going up in translateY while I scroll down (be hidden) and appear / go down when I scroll up. I've already got all working but I'm just missing this calc()
part.
I'm just not sure how to handle this while combining both things. Does anyone have any experience with this? Any help would be appreciated.
Thanks for your time, and thanks for reading!
Edit: Here's a working example of what I want to achieve. I'm not using calc()
there and that's the problem, but this is just to show the desired goal.