Answer the question
In order to leave comments, you need to log in
React-GSAP is it possible to separate the logic of general animation and animated components?
Hello! I'm doing an experimental project. For animation I use react-gsap.
The structure is as follows:
src
- components
- pages
- store
- styles
- tweens Typical
component pseudocode
import React from 'react';
// подключаю нужные стилевые элементы
import {Button} from '../styles/Button'
import {Blob, Blobs} from '../styles/Blobs'
// подключаю нужные мне анимации
import BlobsAnimated from '../tweens/Blobs'
// если надо, инъекчу стор, но тут я это опущу
//... render
<Button>
{children}
<Blobs>
<BlobsAnimated
duration={1}
delay={0.1}
>
<Blob />
<Blob />
<Blob />
<Blob />
</BlobsAnimated>
</Blobs>
</Button>
import React from 'react';
import { Tween } from 'react-gsap';
export default ({ children, duration, delay }) => (
<Tween
staggerFrom={{
//...
}}
duration={duration}
stagger={delay}
>
{children}
</Tween>
);
// src/tweens.index.js
import React from 'react';
import {Timeline} from 'react-gsap';
//... импорт всех твинов
export default class extends React.Component {
render () {
return (
<Timeline
add={LogoAnimated}
add={NavAnimated}
add={BlobAnimated}
// etc
/>
// or
<Timeline>
<LogoAnimated />
<NavAnimated />
<BlobAnimated />
</Timeline>
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question