博客
关于我
微信小程序动画效果方法封装
阅读量:236 次
发布时间:2019-02-28

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

??????????????????????????????????????

?WXML???????

??????????????????WXML?????????????????????????????????view?div?????animation?????????????????

????????bindtap????????????

???????animation????????????????????{}????????????

?JavaScript?????

????????????JavaScript?????????.js????????wx.createAnimation???????????????????????????????

?????????????????

function bindViewTap() {    var animation = wx.createAnimation({        duration: 3000, // ??????        timingFunction: 'linear', // ??????        delay: 0, // ??????        transformOrigin: '50%,50%,0' // ???????    });    // ??????    animation.rotate(360).scale(2).translate(10, -20).step();    animation.rotate(-360).scale(1).translate(0).step();    // ??????    this.setData({        animationData: animation.export()    });}

??????

????????????????animation???????????????????????????????????????

animation.rotate(360).scale(2).translate(10, -20).step();// ??????360???????????????10?????-20????????????????

???????????????????????????????????????

???????

?????????????????????????????????????????????app.js????????getApp()??????????????

?????????????

// app.jsfunction slideUpShow(that, animationName, px, opacity) {    var animation = wx.createAnimation({        duration: 800,        timingFunction: 'ease'    });    animation.translateY(px).opacity(opacity).step();        // ???????????animationName    var json = '{"' + animationName + '":""}';    json = JSON.parse(json);    json[animationName] = animation.export();        that.setData(json);}

???????????????

// pages/index/index.jsthis.app.slideUpShow(this, 'firstSlideUp', -200, 1);setTimeout(function() {    this.app.slideUpShow(this, 'secondSlideUp', -200, 1);}.bind(this), 200);

????

  • ???????????????????????????????????????????????
  • ???????????????????????????????
  • ?????????????????????????????????????????
  • ??????????????????????????????????

    转载地址:http://pasp.baihongyu.com/

    你可能感兴趣的文章
    Python基础: with模式和__enter__ 和 __exit__
    查看>>
    Python基础(7)--函数
    查看>>
    Python基础部分-while循环,格式化输出
    查看>>
    Python基础语法:顺序语句结构
    查看>>
    Python基础语法:理解代码与写代码
    查看>>
    Python基础语法:条件和分支
    查看>>
    Python基础语法:基本数据类型(数字类型和布尔类型)
    查看>>
    Python基础语法:基本数据类型(列表)
    查看>>
    Python基础语法:内置函数
    查看>>
    Python基础语法:你不得不知的几种变量类型
    查看>>
    Python基础语法教程,零基础入门到精通,看完这一篇就够了
    查看>>
    Python基础语法与执行脚本的3种方式
    查看>>
    python基础语法
    查看>>
    python基础语法
    查看>>
    python系列【仅供参考】:python测试开发基础---multiprocessing.Pool
    查看>>
    Python基础综合练习
    查看>>
    Python基础练习之一输出10000以内的阿姆斯特朗数
    查看>>
    Python基础系列讲解—动态类型语言的特点
    查看>>
    python基础系列四:字符串,列表,字典,元组之间的转换
    查看>>
    python基础篇(9):模块
    查看>>