码迷,mamicode.com
首页 > 其他好文 > 详细

基于taro封装底下浮动弹窗组件

时间:2019-03-24 18:48:29      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:view   ack   line   one   float   extends   scroll   return   dex   

先看效果图:

技术图片

 

jsx:

import Taro, { Component } from ‘@tarojs/taro‘
import { View, Image } from ‘@tarojs/components‘
import closeImg from ‘../../images/icons/close.png‘
import ‘./FloatLayout.scss‘

interface IProps {
    isOpened: boolean,
    onClose: Function,
    title: string,
}

class FloatLayout extends Component<IProps, {}> {

    state = {
    }

    handleClose () {
        this.props.onClose()
    }

    render () {
        const {isOpened, title} = this.props
        return (
            <View className={isOpened ? "float-layout active" : "float-layout"}>
                <View className=‘float-layout__overlay‘ onClick={this.handleClose.bind(this)}></View>
                <View className=‘float-layout__container layout‘>
                    <View className=‘layout-header  xmg-border-b‘>
                        {title}
                        <Image src={closeImg} className=‘close-img‘/>
                    </View>
                    <View className=‘layout-body‘>
                        {this.props.children}
                    </View>
                </View>
            </View>
        )
    }
}

export { FloatLayout }

scss:

.flolayout {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    visibility: hidden;
    z-index: 810;
    transition: visibility 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
    &.active {
        visibility: visible;
        .flolayout__overlay {
            opacity: 1;
        }
        .flolayout__container {
            transform: translate3d(0, 0, 0);
        }
    }
}
.flolayout__overlay {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 150ms ease-in;
}
.flolayout__container {
    position: absolute;
    bottom: 0;
    width: 100%;
    min-height: 600px;
    max-height: 950px;
    background-color: #fff;
    border-radius: 32px 32px 0px 0px;
    transform: translate3d(0, 100%, 0);
    transition: -webkit-transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
    transition: transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
    transition: transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1),
        -webkit-transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
}

.flolayout .layout-header {
    position: relative;
    padding: 30px 0;
    text-align: center;
    .close-img {
        position: absolute;
        right: 28px;
        top: 36px;
        width: 36px;
        height: 36px;
    }
}
.flolayout .layout-header__title {
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
    font-size: 32px;
    display: block;
    padding-right: 80px;
}
.flolayout .layout-header__icon {
    line-height: 1;
    position: absolute;
    top: 50%;
    right: 18px;
    padding: 10px;
    transform: translate(0, -50%);
}

.flolayout .layout-body {
    font-size: 28px;
    padding: 20px;
    height: 602px;
}
.flolayout .layout-body__content {
    position: relative;
    height: 500px;
    overflow-y: scroll;
}

 

 组件必须传三个参数,

isOpened: boolean, //控制显示
onClose: Function, //处理关闭弹窗逻辑
title: string //标题

基于taro封装底下浮动弹窗组件

标签:view   ack   line   one   float   extends   scroll   return   dex   

原文地址:https://www.cnblogs.com/pjl43/p/10589456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!