-
Notifications
You must be signed in to change notification settings - Fork 0
feat: estrutura de animação (motion base) #73
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
Open
Luana-lua
wants to merge
10
commits into
main
Choose a base branch
from
feature/motion-base
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9e7e8df
infraestrutura de animação
d25fedb
Apply suggestions from code review
oEnzoRibas b4d2609
fix: correcao dos comentarios dos componentes de teste
0b08d38
fix: documentacao com docstring e responsividade para desktop e mobile
0f63635
fix: prevendo possivel erro adicionando null check
8b5ba82
instrucao pra visualizar componente de teste
fdea39c
adiciona responsividade ao componente e documentacao
042ceab
refactor: melhora flexibilidade e animacao dos hooks e a documentacao
38f5df4
Merge branch 'feature/motion-base' of https://github.com/Code-EJ/land…
e772a9e
Refactor scroll hooks and MotionDemo animations
oEnzoRibas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import React from "react"; | ||
| import { useGSAP } from "@gsap/react"; | ||
| import gsap from "gsap"; | ||
| import { ScrollTrigger } from "gsap/ScrollTrigger"; | ||
|
|
||
| // Registro obrigatório dos plugins | ||
| gsap.registerPlugin(ScrollTrigger, useGSAP); | ||
|
|
||
| /** | ||
| * LaptopSection | ||
| * Componente de teste para animação avançada com ScrollTrigger. | ||
| * | ||
| * Objetivo: | ||
| * - Testar performance com Pin + Scrub | ||
| * - Simular abertura de um laptop em 3D | ||
| * - Validar fluidez de animações sincronizadas com scroll | ||
| * | ||
| * Recursos: | ||
| * - Pin (fixa a seção durante scroll) | ||
| * - Scrub (animação segue o scroll) | ||
| * - Transformações 3D (rotateX + perspective) | ||
| * - Responsividade básica (mobile e desktop) | ||
| * | ||
| * Observações: | ||
| * - Usa useGSAP para garantir cleanup automático | ||
| * - Inclui verificações de null para evitar erros em strict mode | ||
| */ | ||
| const LaptopSection: React.FC = () => { | ||
oEnzoRibas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const containerRef = React.useRef<HTMLDivElement>(null); | ||
| const laptopRef = React.useRef<HTMLDivElement>(null); | ||
| const screenRef = React.useRef<HTMLDivElement>(null); | ||
|
|
||
oEnzoRibas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| useGSAP( | ||
| () => { | ||
|
|
||
| // Verificações de segurança - null checks | ||
| // Se algum ref essencial não estiver pronto, não builda a timeline | ||
| if (!containerRef.current || !laptopRef.current || !screenRef.current) { | ||
| return; | ||
| } | ||
|
|
||
| const mm = gsap.matchMedia(); | ||
|
|
||
| mm.add({ | ||
| isDesktop: "(min-width: 1024px)", | ||
| isMobile: "(max-width: 1023px)" | ||
| }, (context) => { | ||
| // Verifica a condição atual | ||
| const isDesktop = context.conditions?.isDesktop; | ||
|
|
||
| const tl = gsap.timeline({ | ||
| scrollTrigger: { | ||
| trigger: containerRef.current, | ||
| start: "top top", | ||
| end: "+=1000", | ||
| scrub: 1, | ||
| pin: true, | ||
| // Adicionado para evitar flashes visuais e jump no pin | ||
| anticipatePin: 1, | ||
| }, | ||
| }); | ||
|
|
||
| // Ajuste de escala pra Mobile | ||
| if (!isDesktop) { | ||
| gsap.set(laptopRef.current, { scale: 0.6 }); | ||
| } else { | ||
| gsap.set(laptopRef.current, { scale: 1 }); | ||
| } | ||
|
|
||
| tl.to(screenRef.current, { | ||
| rotateX: 0, | ||
| ease: "power2.inOut", | ||
| }) | ||
| .to(".laptop-text", { | ||
| opacity: 1, | ||
| y: isDesktop ? -20 : -10, | ||
| stagger: 0.2, | ||
| duration: 0.5 | ||
| }, "-=0.5"); | ||
| }); | ||
|
|
||
| // O useGSAP já lida com o cleanup internamente, | ||
| // mas o mm.revert() é bom para limpar as queries de mídia. | ||
| return () => mm.revert(); | ||
| }, | ||
| { scope: containerRef } | ||
| ); | ||
|
|
||
| return ( | ||
| <div | ||
| ref={containerRef} | ||
| className="min-h-screen w-full bg-black flex flex-col items-center justify-center overflow-hidden" | ||
| > | ||
| <div className="text-center mb-10 px-4"> | ||
| <h2 className="laptop-text opacity-0 text-3xl md:text-4xl font-bold text-white translate-y-10"> | ||
| Performance de Elite | ||
| </h2> | ||
| <p className="laptop-text opacity-0 text-sm md:text-base text-gray-400 translate-y-10"> | ||
| Sente o poder do hardware sob o teu comando. | ||
| </p> | ||
| </div> | ||
|
|
||
| <div | ||
| ref={laptopRef} | ||
| className="relative w-[280px] md:w-[300px] h-[180px] md:h-[200px] [perspective:1200px]" | ||
| > | ||
| <div | ||
| ref={screenRef} | ||
| className="w-full h-full bg-gray-800 border-4 border-gray-700 rounded-t-lg shadow-inner" | ||
| style={{ | ||
| transform: "rotateX(-95deg)", | ||
| transformOrigin: "bottom center", | ||
| backfaceVisibility: "hidden" | ||
| }} | ||
| > | ||
| <div className="flex flex-col items-center justify-center h-full bg-blue-900/20"> | ||
| <div className="text-blue-400 font-mono text-[10px] animate-pulse"> | ||
| {">"} SYSTEM READY | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="w-[300px] md:w-[320px] h-[10px] bg-gray-700 absolute -bottom-1 -left-[10px] rounded-b-md shadow-xl border-t border-gray-500"></div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default LaptopSection; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.