At the moment, I have a stationary image in the center of my screen that moves horizontally when scrolling with the mouse. Now, I want to include a screen above and below this element, each with a height of 100vh. However, when I attempt to do so, the fixed components shift to the top screen, which I intended to leave empty. I've tried adding a margin-top: 100vh to the image, but it ends up moving off-screen.
I am faced with two challenges here. Firstly, how can I position this component in the middle of the screen after a 100vh window, and secondly, how can I ensure that the animations only commence once the user has reached that specific component? Currently, in my project setup, the image and text move with the user's scroll, so introducing a 100vh screen above triggers the scroll and thus initiates my animations prematurely.
For a better understanding, view the code on CodeSandbox in fullscreen mode: https://codesandbox.io/s/interesting-bouman-lokt5?file=/src/App.js
Code:
{/* <div style={{height:"100vh"}}></div> */}
<div className="App" ref={ref}>
<h1 id="title" className="titles">
Random Title
</h1>
<section id="block1" className="blocks"></section>
<figure id="passport">
<img
alt="passport"
src="https://cdn.britannica.com/87/122087-050-1C269E8D/Cover-passport.jpg"
/>
</figure>
<h2 id="text1" className="titles text1">
Random Text 1
</h2>
<section id="block2" className="blocks"></section>
<h2 id="text2" className="titles text2">
Random Text 2
</h2>
<section id="block3" className="blocks"></section>
<h2 id="text3" className="titles text3">
Random Text 3
</h2>
<section id="block4" className="blocks"></section>
</div>
{/* Stop Scrolling Animation */}
{/* <div>Content</div> */}