问题是我有组件的层次结构。我有一个父html" target="_blank">组件、子组件和子组件(便于在代码中导航)。在父级组件中,我有一个ScrollView和一个变量(不是动画变量)contentOffset(处于父级状态),每当滚动发生时,该变量都会发生变化。变量间隔介于[-100100]之间。
父成分
constructor(props) {
super(props);
this.state = {
contentOffset: 1
}
this.onScrollEvent = this.onScrollEvent.bind(this);
}
onScrollEvent = event => {
this.setState(
{
contentOffset: event.nativeEvent.contentOffset.y,
}
)
}
render() {
return (
<ScrollView
showsVerticalScrollIndicator={false}
onScroll={this.onScrollEvent.bind(this)>
<ChildOne
animation={this.state.contentOffset}/>
);
}
子组件
constructor(props) {
super(props);
}
render() {
return (
<NestedChild
handleClick={this.openSettingsInHeader}
header="What the..."
transformAnimation={this.props.animation}/>
);
}
子组件
constructor(props) {
super(props);
this.state = {
AnimatedTextValue: new Animated.Value(0),
ProfileOffset: this.props.transformAnimation
}
}
render() {
const animatedStyles = {
transform: [
{ scale: this.props.transformAnimation }]} <== if I'll pass it here the scale would be huge [-100,100], so we need to interpolate this, but the variable that's passed through props is not animated value and .interpolate function is not working
return (
<Animated.Text style={[styles.nameStyle,animatedStyles]}>Hi</Animated.Text>
);
}
我将contentOffset变量作为prop传递给子组件,然后传递给子组件的子组件。如果我使用代码,缩放间隔将是相同的[-100100](文本将被缩放到我们看不到的程度)。为此,在React Native中,我们有函数。在动画库中插值,该动画库采用输入间隔并给出输出(因此,当contentOffset为-100时,我们将按比例缩小/放大,例如仅在4个点上,而不是在100上。
但是我们不能传递内容偏移变量,因为它不是动画。价值
这是插值的正确代码,它可以工作,但子组件的AnimatedTextValue未与父组件状态的contentOffset变量链接
const headerTranslate = this.state.AnimatedTextValue.interpolate({
inputRange: [-100, 100],
outputRange: [4,-4],
extrapolate: 'clamp'
});
如何将此变量链接到孩子的子动画。价值
为什么不使内容偏移动画。价值?然后像这样使用setValue而不是setState:
constructor(props) {
super(props);
this.state = {
contentOffset: new Animated.Value(0)
};
this.onScrollEvent = this.onScrollEvent.bind(this);
}
onScrollEvent = event => {
this.state.contentOffset.setValue(event.nativeEvent.contentOffset.y);
}
如何在recyclerview中滚动到具有偏移量的特定位置? 我用过 我也曾经 此外,我使用了skrolltopoplace 但似乎没有一个适合我。 如果有人知道这件事,你能帮我吗 使现代化 功能,其中我设置适配器的我的回收站
我将非常感谢任何帮助我可以得到以下。我有一个包含降水预测的excel电子表格。该表有两列(日和降水),有超过20,000行,即超过20,000天的降水。我把这张纸加载到AnyLogic上。我使用的是一个系统动力学模型,有一个叫做降雨的动态变量。在模拟的每一天中,我都希望降雨从加载的数据库中提取值,但不知道如何将动态变量链接到数据库。我已经尝试了以下方法:插入一个名为ProjectedRainfal
我正在尝试理解下面的QuickSort实现在Java中是如何工作的。我已经了解了大部分,但我很困惑它是如何做任何事情的。当您将变量传递给函数并对其进行修改时,它通常不会修改传入的原始变量。那么为什么这种没有返回类型的快速排序实现会修改传入的数组呢?
问题内容: 嗨,我希望animation.view像一个圆圈一样移动。我以 鼻窦想到了这一点,但没有用。有人知道该怎么做吗?我不想旋转 视图。它应该绕圈移动。我是新来的本地人。 如果有人可以帮助我,那就太好了。 问题答案: 你算算,并Y与三角函数功能。 对应,并且是对应于。 尽管不支持函数回调,但是您可以将其分为几部分进行模拟(我在 代码示例中选择了50个): 完整代码:
我正在使用改装库,我想从OpenWeatherPi获取天气预报。 我有这个。
我正在编写一个创建用户的简单任务。作为该任务的一部分,我想从defaults/main.yml中读取密码 默认值/main.yml test_user:testuser test_group:testgroup test_user_password:somepassword 我的任务文件如下 -名称:“为TestUser创建组” · 组: 名称:“{{test_group}}” 状态:当前 -名