繁体   English   中英

React-Spring 为什么关闭 animation 不起作用?

[英]React-Spring Why doesn't the closing animation work?

我正在使用 spring 版本 8.0.27 执行模式 window animation。 当我打开 window 时,animation 工作,它从底部移出,但是当我关闭 window 时,它就消失了,没有 animation。

我看了示例,那里的代码是一样的,但是关闭时它们有 animation,我不明白我的问题是什么,我根据文档做了一切。

关闭时如何使animation顺利? 我认为休假财产会影响这个

 const transitions = useTransition(show, null, {
    from: { opacity: 0, transform: `translateY(100%)` },
    enter: { opacity: 1, transform: `translateY(0%)` },
    leave: { opacity: 0, transform: `translateY(100%)` },
  });

return (
    <>
      {show && (
        <ModalBackground>
          {transitions.map(
            ({ item, key, props: style }) =>
              item && (
                <animated.div
                  style={style}
                  key={key}
                >
                  <ModalContainer>
                    <ModalClose onClick={() => setShow((prev) => !prev)}>
                      <IoClose />
                    </ModalClose>
                  </ModalContainer>
                </animated.div>
              )
          )}
        </ModalBackground>
      )}
    </>
  );

问题是,当我关闭时,组件立即被卸载,animation 没有时间工作。 我刚刚删除了show &&并且一切正常

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM