Skip to content

Commit

Permalink
added animatsions for the contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouncer27 committed Jun 20, 2023
1 parent 0867262 commit 4c26409
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/shared/formParts/TextareaField.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import styled from "styled-components"
import { colors, B2White } from "../../../styles/helpers"
import { B2White } from "../../../styles/helpers"
const TextareaField = ({
value,
handler,
Expand Down
112 changes: 108 additions & 4 deletions src/components/templates/contact/ContactIntro.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,122 @@
import React from "react"
import React, { useEffect } from "react"
import styled from "styled-components"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { B1White, B2White, H1White, medWrapper } from "../../../styles/helpers"

import mountains from "../../../images/mountains-icon.png"
import { Link } from "gatsby"

import { gsap } from "gsap"
import { ScrollTrigger } from "gsap/ScrollTrigger"
gsap.registerPlugin(ScrollTrigger)

const ContactIntro = ({ data }) => {
const image = getImage(
data?.contactIntroLogo?.localFile?.childImageSharp?.gatsbyImageData
)
const alt = data?.contactIntroLogo?.altText

useEffect(() => {
const mainLogo = document.querySelector(
"#contact-intro .contact-intro__images--logo"
)
const mountainOne = document.querySelector("#contact-intro .mountain-one")
const mountainTwo = document.querySelector("#contact-intro .mountain-two")

const mainTitle = document.querySelector(
"#contact-intro .contact-intro__content--title"
)
const mainContent = document.querySelector(
"#contact-intro .contact-intro__content--paragraph"
)

console.log("mainTitle", mainTitle)

gsap
.timeline({
scrollTrigger: {
trigger: "#contact-intro",
markers: false,
start: "-65px",
end: "bottom ",
scrub: false,
},
})
.add("start")
.fromTo(
mainLogo,
{
y: -300,
autoAlpha: 0,
},
{
ease: "power2.out",
y: 0,
autoAlpha: 1,
duration: 1.5,
}
)
.fromTo(
mountainOne,
{
x: -300,
autoAlpha: 0,
},
{
ease: "power2.out",
x: 0,
autoAlpha: 1,
duration: 1.5,
},
"start+=0.5"
)
.fromTo(
mountainTwo,
{
x: 300,
autoAlpha: 0,
},
{
ease: "power2.out",
x: 0,
autoAlpha: 1,
duration: 1.5,
},
"start+=0.5"
)
.add("second")
.fromTo(
mainTitle,
{
y: 100,
autoAlpha: 0,
},
{
ease: "power2.out",
y: 0,
autoAlpha: 1,
duration: 1,
},
"second-=0.5"
)
.fromTo(
mainContent,
{
y: 100,
autoAlpha: 0,
},
{
ease: "power2.out",
y: 0,
autoAlpha: 1,
duration: 1,
},
"second"
)
}, [])

return (
<StyledSection>
<StyledSection id="contact-intro">
<div className="wrapper">
<div className="contact-intro__top-title">
<h1>{data.contactIntroTopTitle}</h1>
Expand All @@ -24,13 +128,13 @@ const ContactIntro = ({ data }) => {
</Link>
</div>
<div
className="contact-intro__images--mountains"
className="contact-intro__images--mountains mountain-one"
style={{
backgroundImage: `url(${mountains})`,
}}
/>
<div
className="contact-intro__images--mountains"
className="contact-intro__images--mountains mountain-two"
style={{
backgroundImage: `url(${mountains})`,
}}
Expand Down
39 changes: 36 additions & 3 deletions src/components/templates/contact/ProductsDisplay.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import React from "react"
import React, { useEffect } from "react"
import styled from "styled-components"
import { GatsbyImage, getImage } from "gatsby-plugin-image"
import { medWrapper } from "../../../styles/helpers"

import { gsap } from "gsap"
import { ScrollTrigger } from "gsap/ScrollTrigger"
gsap.registerPlugin(ScrollTrigger)

const ProductsDisplay = ({ data }) => {
useEffect(() => {
gsap
.timeline({
scrollTrigger: {
trigger: "#products-section",
markers: false,
start: "top 45%",
toggleActions: "play none none none",
},
})
.add("start")
.fromTo(
`#products-section .pro-item`,
{
autoAlpha: 0,
y: 100,
},
{
autoAlpha: 1,
ease: "power2.out",
y: 0,
duration: 1.25,
stagger: {
each: 0.25,
},
}
)
}, [])

return (
<StyledDiv>
<StyledDiv id="products-section">
<div className="wrapper">
{data.productsDisplayProducts.map((item, index) => {
const image = getImage(
Expand All @@ -14,7 +47,7 @@ const ProductsDisplay = ({ data }) => {
const alt = item?.productImage?.altText

return (
<Item key={index}>
<Item className="pro-item" key={index}>
<div className="item-image">
<GatsbyImage image={image} alt={alt} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/templates/home/Flavours.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Flavours = ({ data }) => {
.timeline({
scrollTrigger: {
trigger: "#flavours-section",
markers: true,
markers: false,
start: "top 30%",
toggleActions: "play none none none",
},
Expand Down

0 comments on commit 4c26409

Please sign in to comment.