react-spring - React Spring中的高度动画不起作用
问题描述
我一直在用 React Spring 制作动画比例。以下工作正常:
<ul>
{items.map((item, index) => {
if (index === items.length - 1) {
return (
<Spring
key={item.id}
from={{
progress: 0,
}}
to={{
progress: 1,
}}
config={{ delay: 300, duration: 300 }}
>
{({ progress }) => {
const style = { transform: `scale(${progress})` };
return <Item style={style} {...item} />;
}}
</Spring>
);
}
return <Item {...item} />;
})}
</ul>
但是,当我尝试对高度0
进行动画处理时,auto
它不起作用。使用 console.log 似乎style
道具只是返回height: 'auto'
而没有任何转换。
<ul>
{items.map((item, index) => {
if (index === items.length - 1) {
return (
<Spring
key={item.id}
from={{
height: 0
}}
to={{
height: 'auto'
}}
config={{ delay: 300, duration: 300 }}
>
{(style) => {
console.log(style)
return <Item style={style} {...item} />;
}}
</Spring>
);
}
return <Item {...item} />;
})}
</ul>
解决方案
推荐阅读
- office-js - Office word web addin中的拖放操作
- node.js - Webpack 生产构建样式不出现
- php - 权限被拒绝:无法打开索引目录:/var/www/html/
- dynamics-crm - 在 Dynamics CRM 统一界面中的查找字段下隐藏或删除“更改视图”选项
- c# - 在 C# 中是否可以通过反射检查方法是否是迭代器?
- phaser-framework - Phaser 3 - 设置图形对象的锚点
- java - 如何使用 forEach() 方法通过 Java 8 迭代 AWS 预留 EC2 实例?
- react-native - React modal 元素不覆盖屏幕的左侧
- javascript - 在 redux saga 中使用 setTimeOut 内的 yield
- angular - 如果已经定义了两个字段,则 ngx-formly 自动填充三个字段之一