Jump to content
Search Community

Cant change start marker position

Fahad247 test
Moderator Tag

Recommended Posts

/* eslint-disable jsx-a11y/alt-text */
 
import Head from "next/head";
 
import Image from "next/image";
import { Inter, Monoton, Pacifico, Permanent_Marker } from "next/font/google";
import styles from "@/styles/Home.module.css";
// const fbt = FrederickaTheGreat({ subsets: ["latin"],weight: ['400'], });
import Logo from "./components/logo";
import { useEffect, useRef, useState,useLayoutEffect } from "react";
import Link from "next/link";
import { gsap } from "gsap/dist/gsap.js";
import ScrollTrigger from "gsap/dist/ScrollTrigger.js";
import Poster from "./components/poster";
import SplitType from "split-type";
import Nav from "./components/nav";
gsap.registerPlugin(ScrollTrigger);
 
export default function Home() {
const myElement = useRef();
 
const handleDone = () => {
console.log(`Done after 5 loops!`);
};
 
const [isVisible, setIsVisible] = useState(false);
 
const [st, setSt] = useState([]);
// const [ani,setAni] = useState([]);
const [ani, setAni] = useState({});
const [anima, setAnima] = useState([]);
 
useEffect(() => {
const svSt = {
display: "none",
};
setSt(svSt);
 
const timer = setTimeout(() => {
const svSt = {};
setSt(svSt);
console.log("showing");
}, 4050);
 
return () => clearTimeout(timer);
}, []);
useEffect(() => {
setAnima({ display: "none" });
const timer = setTimeout(() => {
setAni(styles.open);
setAnima({ display: "block" });
 
const text = new SplitType(myElement.current, { types: "words, chars" });
setIsVisible(true);
gsap.fromTo(
text.chars,
{
opacity: 0,
},
{
opacity: 1,
y: 0,
stagger: 0.05,
delay: 0.2,
duration: 0.1,
}
);
 
// console.log("showing");
}, 4100);
 
// const observer = new IntersectionObserver((entries) => {
// entries.forEach((entry) => {
// if (entry.intersectionRatio > 0) {
// // console.log(entry.intersectionRatio > 0);
 
// const timer = setTimeout(() => {
// setIsVisible(true);
// console.log("showing");
// }, 2000);
// return () => {
// clearTimeout(timer);
// };
// } else {
// setIsVisible(false);
// }
// },{
// threshold:1
// });
// });
 
// observer.observe(circleRef.current);
return () => {
clearTimeout(timer);
// observer.disconnect();
};
}, []);
 
const circleRef = useRef(null);
 
function startMove(e) {
move(e);
}
function move(e) {
document.querySelector("#buble1").style.marginLeft = `${e.pageX / 70}px`;
document.querySelector("#buble1").style.marginTop = `${e.pageY / 70}px`;
document.querySelector("#buble2").style.marginLeft = `${e.pageX / 70}px`;
document.querySelector("#buble2").style.marginTop = `${e.pageY / 70}px`;
// console.log(e.pageX);
}
 
const labMain = useRef();
const posterBox = useRef();
useEffect(() => {
console.clear();
 
window.addEventListener("resize", () => {
ScrollTrigger.refresh();
});
 
// let tl = gsap.timeline({
// scrollTrigger: {
// trigger: ".secBox",
// start: "top 30%",
// end: "bottom bottom",
// markers: true,
// scrub: "0.6",
 
// markers: {
// startColor: "orange",
// endColor: "blue",
// fontSize: "18px",
// fontWeight: "bold",
// indent: 20
// },
 
// }
// });
let tl = gsap.timeline({
scrollTrigger: {
trigger: ".secBox",
start: "top 20%",
end: "center 50%",
markers: true,
scrub: "0.6"
}
});
 
tl.to(".secBox", {
opacity: 1,
x: 100
});
 
tl.to(".secBox", {
opacity: 1,
x: 100
});
 
return () => {
tl.kill();
};
}, []);
 
return (
<>
<Head>
<title>Md.Fahad.Ali</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<div className={styles.loading}>
<Logo />
</div>
<div
className={`scrollerMain `}
style={st.length == 0 ? { display: "none" } : st}
>
<div className={styles.posterbox} ref={posterBox}>
<Nav />
<div className={styles.poster}>
<Poster />
</div>
</div>
<div ref={labMain} className={styles.secondBox}>
<div className={`secBox ${styles.labMain}`}></div>
</div>
</div>
</main>
</>
);
}
 
Please help me to fix the code :)
 
image.png.a84936dae8dc66a38d08707d3008f4d6.png
Link to comment
Share on other sites

Hi there! Apologies for the lack of response so far, but it looks like people are struggling to help with this question. Vague details like 'it's broken' or 'I can't change the start marker position' are very difficult for people to help with. What have you tried? Why do you think you can't change the position? How can we replicate the issue? Here are some tips that will increase your chance of getting a solid answer:
 

  • A clear description of the expected result - "I am expecting the purple div to spin 360degrees"
  • A clear description of the issue -  "the purple div only spins 90deg"
  • A list of steps for someone else to recreate the issue - "Open the demo on mobile in IOS safari and scroll down to the grey container" 
  • A minimal demo - if possible, using no frameworks, with minimal styling, only include the code that's absolutely necessary to show the issue. Please don't include your whole project. Just some colored <div> elements is great.

 

Also, I noticed you're using React but you're not doing proper cleanup. I'd strongly recommend reading this: 

 

If you still need help, please make sure you provide a minimal demo (like a Stackblitz or CodeSandbox) that isolates the issue and then ask a specific GSAP-related question please. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...