变长动画不起效果

来源:7-5 搜索框动画效果实现

慕侠7197899

2021-02-09

index.js:

			<SearchWrapper>
						<CSSTransition
							in={this.state.focused}
							timeout={200}
							className="slide"
						>
							<NavSearch className={this.state.focused ? "focused" : ""}
								onClick={this.handleInputFocus} onBlur={this.handleInputBlur}></NavSearch>
						</CSSTransition>
						<i className={this.state.focused ? "focused iconfont" : "iconfont"}>&#xe614;</i>
					</SearchWrapper>

style.js:

export const NavSearch = styled.input.attrs({
	placeholder: '搜索'
})`
	width: 160px;
	height: 38px;
	padding: 0 35px 0 20px;
	margin-top: 9px;
	margin-left: 20px;
	box-sizing: border-box;
	border: none;
	outline: none;
	border-radius: 19px;
	background: #eee;
	font-size: 14px;
	color:#777
	&.slide-enter {
		transition: all .2s ease-out;
	}
	&.slide-enter-active {
		width: 240px;	background-color:grey;
	}
	&.slide-exit {
		transition: all .2s ease-out;
	}
	&.slide-exit-active {
		width: 160px;
	}
	&::placeholder {
		color: #999;
	}
	&.focused{
		width:240px
	}
`;

写回答

1回答

Dell

2021-02-12

变长动画 是哪个动画?

0
0

React零基础入门到实战,完成企业级项目简书网站开发

主流新技术 React-redux,React-router4,贯穿基础语法

5275 学习 · 2496 问题

查看课程