React Native Transform Origin

前端 未结 2 1704
后悔当初
后悔当初 2021-01-17 11:11

how do I apply the transform-origin property to a style in react native? I\'ve tried in several ways, but I did not get an event

I tried:



        
相关标签:
2条回答
  • 2021-01-17 11:26

    I have made a lib to achieve transform-origin. react-native-anchor-point

    easy to use

    import { withAnchorPoint } from 'react-native-anchor-point';
    
    getTransform = () => {
        let transform = {
            transform: [{ perspective: 400 }, { rotateX: rotateValue }],
        };
        return withAnchorPoint(transform, { x: 0, y: 0.5 }, { width: CARD_WIDTH, height: CARD_HEIGHT });
    };
    
    <Animated.View style={[styles.blockBlue, this.getTransform()]} />
    

    0 讨论(0)
  • 2021-01-17 11:41

    React native doesn't have any transform origin property yet. maybe in the future

    but with a trick we can achieve this

    0 讨论(0)
提交回复
热议问题