简体   繁体   English

在带有 @emotion/core 的样式组件中使用过渡

[英]Using transition in a styled component with @emotion/core

I am trying to implement a short transition to when a button is clicked.我正在尝试实现到单击按钮时的短暂过渡。 The mechanism that sets the isOpen property works fine.设置isOpen属性的机制工作正常。 My problem is that it won't animate, but only flip the content at once.我的问题是它不会动画,而只会一次翻转内容。 The expectation was that it should create an extra class but it just renders the component with a different class.期望它应该创建一个额外的 class 但它只是用不同的 class 渲染组件。

I tried:我试过了:

const StyledButton = styled(Button)`
    transition: transform 0.25s linear;
    transform: rotate(0deg);
    ${({ isOpen }) => isOpen && css`transform: rotate(180deg)` }
  `;

And also:并且:

    transform: ${({ isOpen }) => isOpen ? 'rotate(180deg)' : 'rotate(0de)' 

What am I doing wrong?我究竟做错了什么?

Thanks谢谢

Maybe a bit late, but i imported the wrong package.也许有点晚了,但我输入了错误的 package。

I used我用了

import { css } from '@emotion/css'

instead of代替

import { css } from '@emotion/react'

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

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