Добавьте весеннюю анимацию, чтобы отреагировать - PullRequest
0 голосов
/ 16 января 2020

Я хотел бы добавить весеннюю анимацию к элементам в реагирующей нативной суперсети. Это прекрасно работает, когда я использую его в других частях нашего интерфейса. Проблема с сеткой заключается в том, что масштабируется вся сетка, а не только отдельный элемент в сетке, нажимаемый пользователем.

Это код, который я использовал в качестве обходного пути, но анимация не совсем такая. Основная причина в том, что у меня нет функции handlePressIn:


  handlePressOut() {
        Animated.spring(this.animatedValue, {
            toValue: 0.99
        }).start(() => {
            Animated.spring(this.animatedValue, {
                toValue: 1,
                friction: 350,
                tension: 150
            }).start()
        })
    }



   <TouchableWithoutFeedback
                onPress={() => {
                    setTimeout(() => {
                        this.cardAction(item, 'own')
                    }, 1000);
                }
                }
                onPressIn={() => {
                    this.sel = index
                    this.setState({ selected: index })
                }}
                onPressOut={() => {
                    this.handlePressOut(index)
                }}
            >
                <Animated.View
                    style={[this.props.style.itemContainer,
                    this.sel == index ? animatedStyle : null,
                    { backgroundColor: '#edc9af' }]}
                >
                    {
                        (item.icon) ?
                            <View style={[this.props.style.addNewView, { justifyContent: 'center', alignItems: 'center', alignSelf: 'center', position: 'absolute' }]}
                            >
                                <Icon name={item.icon} style={this.props.style.addNewIcon} />
                                <Text style={this.props.style.itemName}>{item.name}</Text>
                            </View>
                            :
                            <View style={{ position: 'absolute', justifyContent: 'center', alignItems: 'center' }}>
                                <Text style={this.props.style.itemName}>{item.name}</Text>
                            </View>
                    }
                </Animated.View>
            </TouchableWithoutFeedback >

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...