Horizontal scrolling sticky section
See original GitHub issueHello,
Looking to create a horizontal scrolling section inside a sticky div with the following structure:
<div id="sec01" class="the-height-400vh-section"><!-- this has the same height as does the 400vh width, timing should match -->
<div class="the-sticky-div" id="sticky" data-scroll data-scroll-sticky data-scroll-target="#sec01"><!-- this is stickying to viewport while we scroll -->
<div class="the-overflow-hidden-mask">
<div class="the-width-400vh-scrollable-div" data-scroll data-scroll-direction="horizontal" data-scroll-speed="12" data-scroll-target="#sec01"><!-- we're scrolling this 400vh to the right while we're scrolling the 400vh height of the parent -->
<div class="the-content">
<div class="a-block"></div>
<div class="a-block"></div>
<div class="a-block"></div>
<div class="a-block"></div>
</div>
</div>
</div>
</div>
</div>
The following SCSS applies:
.the-sticky-div {
position: absolute;
top: 0;
height: 100vh;
width: 100%;
overflow-x: hidden;
background: #ccc;
z-index: 1;
}
.the-overflow-hidden-mask {
position: relative;
z-index: 200;
overflow: hidden;
width: 100%;
height: 100%;
background: #000;
}
.the-height-400vh-section {
position: relative;
display: flex;
height: 400vh;
margin-left: 0px;
justify-content: center;
align-items: center;
border-top: 60px none rgba(36, 36, 36, 0.09);
background-color: #fff;
}
.the-width-400vh-scrollable-div {
display: flex;
width: 400vh;
position:relative;
height: 100%;
flex-wrap: wrap;
align-items: center;
will-change: transform;
}
.the-content {
display: flex;
width: 100%;
height: 100%;
padding-bottom: 10vh;
justify-content: flex-start;
align-items: flex-end;
.a-block {
overflow: hidden;
width: 100vw;
height: 100vh;
left:0;
margin-right: 40px;
margin-left: 40px;
flex: 0 0 auto;
border-radius: 6px;
background-color: hsla(0, 0%, 87.1%, 0.72);
box-shadow: 0 0 100px 8px rgba(205, 43, 177, 0.25);
}
}
I have two main issues:
- horizontal scroll initialises too early (when container top enters viewport, not when reached bottom of sticky container)
- horizontal scroll elements start position is not correct (first element scrolls in from right)
The width / height logic seems to make sense although it unfortunately does not work. Any ideas what could be done with the current solution to achieve a similar end result to i.e www.reformcollective.com (elements reach center of viewport > horizontal scroll intialises > horizontal scrolls end with last element and page continues)?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
html - Position sticky not working for horizontal scrolling when ...
If the content is wider than 100% , then on horizontal scroll the sticky element hits the end of the container <div> and,...
Read more >The Sticky Section with Horizontal Scrolling Template
The next section takes up the full viewport and will stick on top, until the horizontal scrolling ends. The section then unsticks and...
Read more >sticky section horizontal scrolling - GSAP - GreenSock
Scroll vertically to scrub the horizontal animation. It also dynamically snaps to the sections in an organic way based on the velocity. The ......
Read more >Sticky + Horizontal Scroll Demo - Webflow
This template uses CSS Sticky and IX2 to showcase a Horizontal Scroll effect on a wide content section.
Read more >Having Fun With The Horizontal Usage Of Position: Sticky In ...
In such a case, as the user is scrolling across each segment, we can use position: sticky to keep the user's information pinned...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does anybody found the way to achieve this without GSAP Scrolltrigger?
Also interested to know if anyone has achieved this without GSAP Scrolltrigger