Skip to content
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

Support Animation API #191

Open
NiuGuohui opened this issue Feb 22, 2024 · 0 comments
Open

Support Animation API #191

NiuGuohui opened this issue Feb 22, 2024 · 0 comments

Comments

@NiuGuohui
Copy link

Like this:

// Component Code
...
 const slide = useRef(new Animated.Value(0)).current;
useEffect(() => {
    const anim = Animated.timing(slide, { toValue: 100 duration: 200, useNativeDriver: true });
    anim.start();
    return () => anim.stop();
}, []);

return <Block transformX={slide} />
...

// Styled Code
const Block = styled(Animated.View)<{ transformX: Animated.Value }>`
    position: absolute;
    top: 2px;
    left: 2px;
    z-index: 9;
    width: 36px;
    height: 24px;
    border-radius: 4px;
    background: #F00;
    transform: translateX(${props => props.transformX});
 `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant