博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
移动端重构系列12——popup
阅读量:7245 次
发布时间:2019-06-29

本文共 1708 字,大约阅读时间需要 5 分钟。

本系列文章,如果没有特别说明,兼容安卓4.0.4+

popup分为两种:一种是内容比较多,直接以全屏显示,如图一;一种是少量内容的popup提示,如图二

 

pop pagepop over

先上demo:

popup page

第一种形式,设计结构如下:

...

因为这种形式内容可能会比较长,有可能会有滚动效果,所以头部(含有关闭按钮)采用固定,动画设计使用translate偏移和opacity来搞定,这里用的是从下面进入视觉范围。通过添加删除active这个class来控制元素显示隐藏,

scss代码如下:

.popup-page{    position: fixed;    top: 0;    bottom: 0;    left: 0;    right: 0;    opacity: 0; background-color: #fff; padding-top: 35px; z-index: $zIndexOverlay + 5; @include translate3d(0, 100%, 0); @extend %transition-transform; &.active{ opacity: 1; @include translate3d(0, 0, 0); } .popup-hd{ position: absolute; left: 0; top: 0; right: 0; height: 35px; line-height: 35px; border-bottom: 1px solid $primary; padding-left: 10px; .btn-close{ position: absolute; right: 0; top: 0; font-size: 30px; width: 35px; text-align: center; cursor: pointer; &:active,&:hover{ background-color: $primary; color: #fff; } } } .popup-bd{ padding: 10px; height: 100%; @extend %scroll-touch; p{ margin-bottom: 10px; } } }

popup over

设计结构如下:

...

这种的首先得计算定位,这次动画采用scale和opacity来搞定,同样通过添加删除active这个class来控制元素显示隐藏

.popup-over{    background-color: #fff;    border-radius: 8px;    position: absolute;    top: 0;    left: 0; width: 200px; padding: 10px; z-index: $zIndexOverlay + 5; opacity: 0; @include transform(translate3d(0, 0, 0) scale(0.815)); @extend %transition-transform; &.active { opacity: 1; @include transform(translate3d(0, 0, 0) scale(1)); } &::before{ @include triangle(top, 10px, #fff); position: absolute; left: 50%; top: -10px; margin-left: -10px; } }

总结

使用transition动画的时候,在动画开始之前先得确保display为非none状态,然后动画结束之后有个transtionend事件可以调用,demo中的overlay的隐藏就是这个调用了这个事件

如需转载,烦请注明出处:

你可能感兴趣的文章
教育行业-班班通应用案例
查看>>
Linux SSH管理用户登录
查看>>
LAMP
查看>>
sendmail,mail,fetion,页面声音实现nagios报警
查看>>
硬链接和软连接
查看>>
nautilus can't be used now,due to an unexpected error解决方法
查看>>
《PHP经典实例(第二版)》(PHP Cookbook, 2nd Edition)中文版,高清扫描版[PDF]
查看>>
Spark On Yarn实战
查看>>
H3C设备与中兴89系列交换机snmp V3配置模板与kali snmpwalk配套测试
查看>>
Python编码问题
查看>>
×××LNMP环境
查看>>
linux 内核代码构架图
查看>>
FTP文件服务器搭建与应用
查看>>
openssl rand 指令解析
查看>>
ubuntu下minicom超级终端的使用方法
查看>>
迅为iTOP-4412核心板调整电压
查看>>
求两个数的最大公约数(辗转相除法)
查看>>
Linux 中gdb调试工具的使用
查看>>
设计模式系列 - 策略模式
查看>>
Windows 2012R2安装KB2919355失败
查看>>