quand j'ajoute le smoothscrollcomponent autour ça casse un peu ma section notamment sur…
- User
quand j'ajoute le smoothscrollcomponent autour ça casse un peu ma section notamment sur des histoires d'animations sur le position fixed/relative:
import { AnimatePresence, motion } from 'framer-motion' import { FormEvent, useEffect, useRef, useState } from 'react' import BtnReseau from '../../Components/BtnReseau'; import SmoothScrollComponent from '../../Components/SmoothScrollComponent';
type Props = { setBgCol: (color: string) => void; }
export default function Contact(props: Props) {
useEffect(() => { setTimeout(() => { window.scrollTo(0, 0) props.setBgCol("var(--dark)") }, 1000); }, []) const pageVariants = { visible: { opacity: 1, y: 0, }, exit: { opacity: 0, y: 30, transition: { duration: 0.5, type: "spring", stiffness: 180, damping: 30, } } } const letterVariant = (i: number) => { return { hidden: { top: -120 - (i + 1) * 40, }, visible: { top: 0, transition: { delay: 1, ease: [0.33, 1, 0.68, 1], duration: 0.6, type: "spring", stiffness: 180, damping: 30, } } } } const titleVariant = { hidden: { top: 50 + "%", scale: window.innerWidth * (window.innerWidth < 1024 ? 0.0025 : window.innerWidth < 2150 ? 0.0015 : 0.001), x: -50 + "%", y: -50 + "%", }, visible: { top: 20 + "%", scale: 1, transition: { delay: 2.5, ease: [0.33, 1, 0.68, 1], duration: 0.6, type: "spring", stiffness: 180, damping: 30, } } } const contentVariant = { hidden: { y: 500, opacity: 0, }, visible: { y: 0, opacity: 1, transition: { delay: 2.5, ease: [0.33, 1, 0.68, 1], duration: 0.6, type: "spring", stiffness: 180, damping: 30, } } } const nameRef = useRef<HTMLInputElement>(null); const emailRef = useRef<HTMLInputElement>(null); const messageRef = useRef<HTMLTextAreaElement>(null); const handleSubmit = (e: FormEvent) => { e.preventDefault(); if (btnState === "loading") return; startLoading(); let name = nameRef.current?.value; let email = emailRef.current?.value; let message = messageRef.current?.value; console.log(name, email, message); fetch('/sendmail', { method: 'POST', body: JSON.stringify({ nom: name, email: email, message: message }), headers: { 'Content-Type': 'application/json' } }).then(() => { stopLoading(); }) .catch(error => { alert("il y a eu une erreur lors de l'envoi du message: " + error); setBtnState("default"); }) } const [btnState, setBtnState] = useState<"default" | "loading" | "loaded">("default"); const btnTextVariants = { default: { opacity: 1, scale: 1, }, exit: { opacity: 0, scale: 0.8, transition: { duration: 0.2, ease: [0.4, 0, 1, 1] } } } const spinnerVariants = { start: { rotate: 0, opacity: 0, scale: 1.4, }, appear: { rotate: 0, opacity: 1, scale: 1, transition: { duration: 0.2, ease: [0.4, 0, 1, 1] } }, spin: { rotate: 360, transition: { duration: 0.7, repeat: Infinity, ease: "linear" } } } const checkmarkVariants = { hiddenFirst: { width: 2, opacity: 0, }, visibleFirst: { width: 21.9409, opacity: 1, transition: { // ma courbe de béziers c'est : 0.86, -0.68,0.23, 1.64 ease: [0.86, -0.68, 0.23, 1.64], duration: 0.4, } }, hiddenSecond: { width: 2, }, visibleSecond: { width: 10.5914, transition: { // ma courbe de béziers c'est : 0.86, -0.68,0.23, 1.64 ease: [0.86, -0.68, 0.23, 1.64], duration: 0.4, } }, } const startLoading = () => { setBtnState("loading"); } const stopLoading = () => { setTimeout(() => { setBtnState("loaded"); }, 2000); } return ( <SmoothScrollComponent> <motion.section id="Contact" initial="visible" exit="exit" variants={pageVariants}> <div className="container-text-anim" aria-hidden> <motion.h2 variants={titleVariant} initial="hidden" animate="visible"> { // fais un span pour chaque lettre "Discutons de votre projet".split("").map((s, i) => { return <motion.span variants={letterVariant(i)} key={i} initial="hidden" animate="visible">{s}</motion.span> }) } </motion.h2> </div> <motion.div className="content" variants={contentVariant} initial="hidden" animate="visible"> <h2 style={{ opacity: 0 }}>Discutons de votre projet</h2> <div className="container-form-reseaux"> <form onSubmit={(e) => handleSubmit(e)}> <div className='title'> <h3>Laissez moi un message!</h3> <p>J’essaierai de répondre au plus vite !⚡️</p> </div> <div className="fields"> <div className="field"> <label htmlFor="name">Nom</label> <input type="text" name="name" id="name" required placeholder='Quel est votre nom?' ref={nameRef} /> </div> <div className="field"> <label htmlFor="email">Adresse e-mail</label> <input type="email" name="email" id="email" required placeholder='Et votre adresse e-mail?' ref={emailRef} /> </div> <div className="field"> <label htmlFor="message">Message</label> <textarea name="message" id="message" required placeholder='Votre message...' ref={messageRef}></textarea> </div> </div> <button type="submit"> <span aria-hidden style={{ opacity: 0 }}>Envoyer</span> <AnimatePresence> {btnState === "default" && <motion.span variants={btnTextVariants} initial="default" exit="exit" style={{ position: "absolute" }}>Envoyer</motion.span>} </AnimatePresence> <AnimatePresence> {btnState === "loading" && <motion.div className="spinner-container" variants={spinnerVariants} initial="start" animate="appear" exit="exit"> <svg className='spinner' width="43" height="43" viewBox="0 0 43 43" fill="none" xmlns="http://www.w3.org/2000/svg"> <mask id="path-1-inside-1_930_195" fill="white"> <path d="M8.22035 16.443C7.61939 16.2224 6.9487 16.5298 6.77511 17.146C5.97128 19.9994 6.0288 23.0365 6.95464 25.8708C8.00083 29.0736 10.0948 31.8308 12.8992 33.6983C15.7036 35.5658 19.0551 36.4347 22.4136 36.1651C25.772 35.8955 28.942 34.503 31.4125 32.212C33.8831 29.9211 35.5104 26.8651 36.0322 23.5364C36.554 20.2078 35.94 16.8004 34.2891 13.8633C32.6382 10.9262 30.0465 8.63046 26.9316 7.34599C24.1751 6.20928 21.1509 5.92315 18.2452 6.50975C17.6176 6.63643 17.2605 7.28206 17.4353 7.89793V7.89793C17.61 8.51381 18.2505 8.86582 18.8797 8.74802C21.2823 8.29822 23.7729 8.5511 26.0478 9.48922C28.6813 10.5752 30.8724 12.5161 32.2682 14.9993C33.6639 17.4824 34.1831 20.3632 33.7419 23.1774C33.3007 25.9915 31.9249 28.5752 29.8362 30.5121C27.7474 32.449 25.0675 33.6263 22.228 33.8542C19.3886 34.0822 16.5551 33.3475 14.1842 31.7687C11.8132 30.1898 10.0429 27.8587 9.15836 25.151C8.39427 22.8118 8.32972 20.3093 8.95921 17.9474C9.12408 17.3288 8.82131 16.6636 8.22035 16.443V16.443Z" /> </mask> <motion.path variants={spinnerVariants} animate="spin" d="M8.22035 16.443C7.61939 16.2224 6.9487 16.5298 6.77511 17.146C5.97128 19.9994 6.0288 23.0365 6.95464 25.8708C8.00083 29.0736 10.0948 31.8308 12.8992 33.6983C15.7036 35.5658 19.0551 36.4347 22.4136 36.1651C25.772 35.8955 28.942 34.503 31.4125 32.212C33.8831 29.9211 35.5104 26.8651 36.0322 23.5364C36.554 20.2078 35.94 16.8004 34.2891 13.8633C32.6382 10.9262 30.0465 8.63046 26.9316 7.34599C24.1751 6.20928 21.1509 5.92315 18.2452 6.50975C17.6176 6.63643 17.2605 7.28206 17.4353 7.89793V7.89793C17.61 8.51381 18.2505 8.86582 18.8797 8.74802C21.2823 8.29822 23.7729 8.5511 26.0478 9.48922C28.6813 10.5752 30.8724 12.5161 32.2682 14.9993C33.6639 17.4824 34.1831 20.3632 33.7419 23.1774C33.3007 25.9915 31.9249 28.5752 29.8362 30.5121C27.7474 32.449 25.0675 33.6263 22.228 33.8542C19.3886 34.0822 16.5551 33.3475 14.1842 31.7687C11.8132 30.1898 10.0429 27.8587 9.15836 25.151C8.39427 22.8118 8.32972 20.3093 8.95921 17.9474C9.12408 17.3288 8.82131 16.6636 8.22035 16.443V16.443Z" fill="#D9D9D9" stroke="#D9D9D9" stroke-width="6" mask="url(#path-1-inside-1_930_195)" /> </svg> </motion.div> } </AnimatePresence> {btnState === "loaded" && ( <div className="checkmark-container"> <svg className='checkmark' width="24" height="18" viewBox="0 0 24 18" fill="none" xmlns="http://www.w3.org/2000/svg"> <motion.rect x="6.77148" y="16.1999" variants={checkmarkVariants} initial="hiddenFirst" animate="visibleFirst" height="2.4243" transform="rotate(-45 6.77148 16.1999)" fill="#D9D9D9" /> <motion.rect x="1.74219" y="7.69458" variants={checkmarkVariants} initial="hiddenSecond" animate="visibleSecond" height="2.46436" transform="rotate(45 1.74219 7.69458)" fill="#D9D9D9" /> </svg> </div> )} </button> </form> <div className="container-reseaux"> <BtnReseau logoPath="/logos/gitlab.svg" logoAlt="logo gitlab" username="@seb_grtd" link="https://gitlab.com/seb_grtd" backgroundColor="linear-gradient(180deg, #E24329 100%, #FC6D26 100%)" /> <BtnReseau logoPath="/logos/github.svg" logoAlt="logo github" username="@sebgrtd" link="https://github.com/sebgrtd" backgroundColor="linear-gradient(180deg, #4B297D 100%, #6F42C1 100%)" /> <BtnReseau logoPath="/logos/discord.svg" logoAlt="logo discord" username="laquant" link="https://discord.com/" backgroundColor="linear-gradient(180deg, #3A4866 100%, #7289DA 100%)" /> </div> </div> </motion.div> </motion.section> </SmoothScrollComponent> ) - Assistant
- User
comment je peux faire pour adapter
- Assistant
- User
- Assistant
- User
sans smoothscrollcomponent: possibilité de scroll en entier, le texte est recouvert par le formulaire quand on scroll (effet voulu) avec: on peut plus scroll tout en bas, tout scroll en même temps, le texte n'est plus fixe
- Assistant
- User
je peux pas changer quoi que ce soit dans le smoothscrollcomponent pour gérer les positions fixed car j'avoue que ça a l'air d'être une galère j'ai juste besoin d'une solution simple, même si ça sous entend d'utiliser un package ou quoi:
import React, { ReactNode, useCallback, useLayoutEffect, useRef, useState } from 'react' import ResizeObserver from "resize-observer-polyfill" import { useViewportScroll, useTransform, useSpring, motion } from "framer-motion"
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.