微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

微信小程序之自定义模态弹窗带动画实例

1、基本需求。


2、案例目录结构

二、程序实现具体步骤

1.弹框index.wxml代码

  1. <!--button-->
  2. <view class="btn"bindtap"powerDrawer"data-statu"open">来点我呀</view>
  3. "drawer_screen""close"wx:if"{{showModalStatus}}"></view>
  4. <!--使用animation属性指定需要执行的动画-->
  5. <!--drawer content-->
  6. "drawer_content">
  7. <label"title col-0"标题</label>
  8. </view>
  9. </label>
  10. </view>
  11. </label>
  12. >
  13. "Email""仅供学习使用"></input>
  14. "top bottom grid"备注</label>
  15. </view>
  16. "btn_ok""close"确定</view>

2.弹框index.wxss代码

.btn {
  • padding20rpx0;
  • textalign center;
  • background #000;
  • }
  • drawer_screen 100 height%;
  • zindex1000;
  • opacity0.5;
  • }
  • drawer_Box {
  • ;
  • -150px50rpx050rpx;
  • }
  • :15px font20px "microsoft yahei"}
  • 210pxy scroll;/*超出父盒子高度可滚动*/
  • btn_ok10pxtop1px solid #E8E8EA;
  • {
  • title {
  • left marginrightinput_h30input_h6060pxinput_view12px background color:#000input {
  • 000}
  • 20pxgrid { displaywebkitBox Box}
  • 11;}
  • fr right;}
  • 3.弹框index.js逻辑代码 
    a.动画部分的功能实现

        /* 动画部分 */
    
  • var animation = wxcreateAnimation({
  • timingFunction"linear"//线性
  • });
  • thisanimation animation// 第3步:执行第一组动画
  • // 第4步:导出动画对象赋给数据对象储存
  • })
  • setTimeout(function() // 执行第二组动画
  • // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
  • animationData animation
  • //关闭
  • (
  • );
  • // 显示
  • showModalStatustrue
  • }
  • 三、案例运行效果

    版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。