Skip to content

Commit

Permalink
Merge pull request layer5io#3951 from Udit-takkar/fix/improve-scroll
Browse files Browse the repository at this point in the history
fix: improve scroll trigger
  • Loading branch information
Shivam-AfA authored Mar 19, 2023
2 parents f5bbd92 + 99b7f1b commit 94893cc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export default function CollaboratorFeatures({ features, theme }) {
const [viewportStatus, setViewportStatus] = useState(
new Array(features.length).fill(false)
);
useGsapTimeline({ trigger: ".test-container3",featureContainerName: ".collaborator-features", yPercent: -400 });
useGsapTimeline({ trigger: ".collaborator-trigger-container",featureContainerName: ".collaborator-features", yPercent: -300 });

return (
<CollaboratorFeaturesWrapper>
<Container className="collaborate-container test-container3">
<Container className="collaborate-container collaborator-trigger-container">
<div className="root">
<div id="featureHeading" className="fixed">
<h1>Collaborate</h1>
Expand All @@ -26,7 +26,7 @@ export default function CollaboratorFeatures({ features, theme }) {
</div>
<ul className="features collaborator-features">
{features.map((feature, index) => (
<li key={index}>
<li className="collaborator-feature-slide" key={index}>
<Feature
{...feature}
onInViewStatusChanged={(state) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const CollaboratorFeaturesWrapper = styled.section`
position: sticky;
top: 0;
z-index: -1;
margin-top:auto;
margin-bottom:auto;
height:100%;
@media (max-width: 1200px) {
min-width: 38rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export default function DesignerFeatures({ features, theme }) {
new Array(features.length).fill(false)
);

useGsapTimeline({ trigger: ".test-container",featureContainerName: ".design-features",yPercent: -400 });
useGsapTimeline({ trigger: ".design-trigger-container",featureContainerName: ".design-features",yPercent: -300 });

return (
<DesignerFeaturesWrapper>
<Container className="designer-container">
<div className="root test-container">
<div className="root design-trigger-container">
<div id="featureHeading" className="fixed" >
<h1>Design</h1>
</div>
Expand All @@ -27,7 +27,7 @@ export default function DesignerFeatures({ features, theme }) {
</div>
<ul className="features design-features">
{features.map((feature, index) => (
<li key={index}>
<li className="design-feature-slide" key={index}>
<Feature
{...feature}
onInViewStatusChanged={(state) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ margin-top: 1rem;
position: sticky;
top: 0;
z-index: 0;
margin-top:auto;
margin-bottom:auto;
height:100%;
@media (max-width: 1200px) {
min-width: 32rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default function VisualizerFeatures({ features, theme }) {
new Array(features.length).fill(false)
);

useGsapTimeline({ trigger: ".test-container2",featureContainerName: ".visualizer-features",yPercent: -400 });
useGsapTimeline({ trigger: ".visualizer-trigger-container",featureContainerName: ".visualizer-features",yPercent: -100 });

return (
<VisualizerFeaturesWrapper>
<Container className="visualizer-container">
<Container className="visualizer-trigger-container">
<div className="root test-container2">
<div id="featureHeading" className="fixed">
<h1>Visualize</h1>
Expand All @@ -25,9 +25,9 @@ export default function VisualizerFeatures({ features, theme }) {
<div className="diagram scroll">
<VisualizerFeaturesDiagram activeExampleIndex={activeExampleIndex} theme={theme} />
</div>
<ul className="features visualizer-features">
<ul className="visualizer-features">
{features.map((feature, index) => (
<li key={index}>
<li className="visualizer-feature-slide" key={index}>
<Feature
{...feature}
onInViewStatusChanged={(state) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from "styled-components";
const VisualizerFeaturesWrapper = styled.section`
margin-top: 1rem;
.visualizer-container {
.visualizer-trigger-container{
padding: 0;
}
Expand Down Expand Up @@ -49,6 +49,9 @@ const VisualizerFeaturesWrapper = styled.section`
position: sticky;
top: 0;
z-index: -1;
margin-top:auto;
margin-bottom:auto;
height:100%;
@media (max-width: 1200px) {
min-width: 32rem;
Expand Down Expand Up @@ -78,7 +81,7 @@ const VisualizerFeaturesWrapper = styled.section`
}
}
}
.features {
.visualizer-features {
z-index: 1;
& > li {
list-style: none;
Expand Down
7 changes: 4 additions & 3 deletions src/sections/Meshmap/FeaturesSection/useGsapTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const useGsapTimeline = ({ trigger, featureContainerName,yPercent }) => {
const RECIPROCAL_GR = 1 / GOLDEN_RATIO;
const DURATION = RECIPROCAL_GR;

useIsomorphicLayoutEffect(() => {

useIsomorphicLayoutEffect(() => {
const context = gsap.context(() => {
const _timeline = gsap.timeline({
defaults: {
Expand All @@ -29,13 +29,14 @@ const useGsapTimeline = ({ trigger, featureContainerName,yPercent }) => {
end: "bottom top",
// markers: true,
scrub: true,
pin: true
pin: true,
toggleActions: "play pause resume reset"
},
});

_timeline.to(featureContainerName,{
yPercent,
ease: "power1.inOut"
ease: "power1.inOut",
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/sections/Meshmap/features/features.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const FeatureWrapper = styled.section`
.root {
display:flex;
& > .text {
font-family:'Qanelas Soft','Qanelas Soft', sans-serif;
opacity:0;
Expand Down

0 comments on commit 94893cc

Please sign in to comment.