Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve scroll trigger #3951

Merged
merged 5 commits into from Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
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
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,10 @@ 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
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
7 changes: 4 additions & 3 deletions src/sections/Meshmap/FeaturesSection/useGsapTimeline.js
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
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