Jump to content
Search Community

BhaskarG

Members
  • Posts

    10
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

BhaskarG's Achievements

  1. @mvaneijgen, @akapowl Thankyou for suggestions
  2. @mvaneijgen Thanks for the reply. My concern is regarding looping through sections in the example in the code pen. There are 5 sections in the html , but after section 5, it loops back to section 1. I do not want this loop behavior. Could you please guide me on how to remove the loop?
  3. Hello, I want to achieve a news app like carousel on a website. I found similar carousel example code pen in GSAP Observer plugin samples but I not familiar how to stop Observer plugin loop in the given code pen example. please guide me. Thanks in advance.
  4. Hello, @GSAP Helper, I am currently trying to convert GSAP JavaScript code to React GSAP code. However, I am feeling confused and unsure about the process. Can you please help me by converting the following code to React.js? Your support will be greatly appreciated. Thank you in advance. this is the code pen of GSAP JavaScript code to be converted to react: https://codepen.io/Bhaskar-Guthula/pen/OJaZbay
  5. Hello, I would like to convert the `Animated Continuous Sections with GSAP Observer` JavaScript code by Brian into a React.js component. However, I encountered the following error: `GSAP target undefined not found. https://greensock.com.` Could anyone assist me in converting the JavaScript code to React.js code? Thank you in advance. my code: import React, { useLayoutEffect, useState, useRef } from "react"; import { gsap } from "gsap" import { Observer } from "gsap/Observer"; import '../GCCarousel.css'; gsap.registerPlugin(Observer); const GCCarousel = () => { const [currentIndex, setCurrentIndex] = useState(0); const main = useRef() let animating = false; useLayoutEffect(() => { let ctx = gsap.context(() => { const sections = document.querySelectorAll("section"); const images = document.querySelectorAll(".bg"); const headings = gsap.utils.toArray(".section-heading"); const outerWrappers = gsap.utils.toArray(".outer"); const innerWrappers = gsap.utils.toArray(".inner"); const wrap = gsap.utils.wrap(0, sections.length); gsap.set(outerWrappers, { yPercent: 100 }); gsap.set(innerWrappers, { yPercent: -100 }); function gotoSection(index, direction) { index = wrap(index); // make sure it's valid animating = true; let fromTop = direction === -1, dFactor = fromTop ? -1 : 1, tl = gsap.timeline({ defaults: { duration: 1.25, ease: "power1.inOut" }, onComplete: () => (animating = false), }); if (currentIndex >= 0) { // The first time this function runs, current is -1 gsap.set(sections[currentIndex], { zIndex: 0 }); tl.to(images[currentIndex], { yPercent: -15 * dFactor }).set(sections[currentIndex], { autoAlpha: 0 }); } gsap.set(sections[index], { autoAlpha: 1, zIndex: 1 }); tl.fromTo( [outerWrappers[index], innerWrappers[index]], { yPercent: (i) => (i ? -100 * dFactor : 100 * dFactor) }, { yPercent: 0 }, 0 ) .fromTo(images[index], { yPercent: 15 * dFactor }, { yPercent: 0 }, 0) .fromTo( headings[index].chars, { autoAlpha: 0, yPercent: 150 * dFactor }, { autoAlpha: 1, yPercent: 0, duration: 1, ease: "power2", stagger: { each: 0.02, from: "random", }, }, 0.2 ); setCurrentIndex(index); } const handleScroll = (event) => { if (!animating) { const direction = event.deltaY < 0 ? -1 : 1; gotoSection(currentIndex + direction, direction); } }; document.addEventListener("wheel", handleScroll); document.addEventListener("touchstart", handleScroll); document.addEventListener("pointerdown", handleScroll); gotoSection(0, 1); return () => { document.removeEventListener("wheel", handleScroll); document.removeEventListener("touchstart", handleScroll); document.removeEventListener("pointerdown", handleScroll); }; }, main); // <- IMPORTANT! Scopes selector text return () => ctx.revert(); }, [currentIndex]); return ( <main ref={main}> <header> <div>Animated Sections</div> <div> <a href="https://codepen.io/BrianCross/pen/PoWapLP">Original By Brian</a> </div> </header> <section className="first"> <div className="outer"> <div className="inner"> <div className="bg one"> <h2 className="section-heading">Scroll down</h2> </div> </div> </div> </section> <section className="second"> <div className="outer"> <div className="inner"> <div className="bg"> <h2 className="section-heading">Animated with GSAP</h2> </div> </div> </div> </section> <section className="third"> <div className="outer"> <div className="inner"> <div className="bg"> <h2 className="section-heading">GreenSock</h2> </div> </div> </div> </section> <section className="fourth"> <div className="outer"> <div className="inner"> <div className="bg"> <h2 className="section-heading">Animation platform</h2> </div> </div> </div> </section> <section className="fifth"> <div className="outer"> <div className="inner"> <div className="bg"> <h2 className="section-heading">Keep scrolling</h2> </div> </div> </div> </section> </main> ); }; export default GCCarousel;
  6. @mvaneijgen Thank you so much for your help!
  7. Hello, I want to achieve a scroll snapping and pinning effect on a website I want each section to scroll one card (height 100vh), and to pin. I don't want a user to scroll through several sections at once. I have been able to achieve the stack cards vertical carousel(code pen attached) with help from this community but I can't figure out how to make it pin, and not scroll multiple sections at once. Thanks in advance.
  8. Thank you so much for your help! Your guidance with creating the carousel has been very helpful to me
  9. Hello, I am new to frontend development and currently working as an intern in the frontend field. I have been assigned a task to create an interactive news app with a scrolling carousel feature. While researching, I came across a sample slider that seems similar to what I need. Could you please assist me with creating the carousel in gsap? I have attached the sample for your reference. Thank you!. 1c100da3-07dc-4b76-8f9d-4efb14afa2f4.mp4
×
×
  • Create New...