constructor() {
super(...arguments)
this.state = {
bgShadow: false,
skuPop: false
}
}
handleClickBtn() {
this.setState(() => {
return {
skuPop: !this.state.skuPop,
bgShadow: !this.state.bgShadow
}
})
}
点击相应的按钮触发handleClickBtn给添加样式
bg-shadow bg-shadow_hide是黑色背景遮罩,
sku-select__box_pop是利用transform: translateY(0%);
弹出来动画
过渡效果主要是transtions
{<View
onClick={this.handleClickBtn.bind(this)}
className={`${bgShadow && "bg-shadow bg-shadow_hide"}`}
></View>}
<View
className={`sku-select__box ${skuPop && "sku-select__box_pop"}`}
>
<SkuSelect />
</View>
.bg-shadow {
height: 200vw;
width: 100vw;
position: fixed;
top: 0;
left: 0;
z-index: 1;
background: transparent;
transition: background 0.3s ease-in;
&_hide {
background: rgba($color: #000000, $alpha: 0.5);
}
}
.sku-select__box {
position: fixed;
bottom: 0;
z-index: 1;
transform: translateY(100%);
transition: transform 0.3s ease-in;
&_pop {
transform: translateY(0%);
}
}