博客
关于我
微信小程序动画效果方法封装
阅读量: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/

    你可能感兴趣的文章
    OpenMMLab | S4模型详解:应对长序列建模的有效方法
    查看>>
    OpenMMLab | 【全网首发】Llama 3 微调项目实践与教程(XTuner 版)
    查看>>
    OpenMMLab | 不是吧?这么好用的开源标注工具,竟然还有人不知道…
    查看>>
    OpenMMLab | 如何解决大模型长距离依赖问题?HiPPO 技术深度解析
    查看>>
    OpenMMLab | 面向多样应用需求,书生·浦语2.5开源超轻量、高性能多种参数版本
    查看>>
    OpenMP 线程互斥锁
    查看>>
    OpenMV入门教程(非常详细)从零基础入门到精通,看完这一篇就够了
    查看>>
    OpenObserve云原生可观测平台本地Docker部署与远程访问实战教程
    查看>>
    openoffice使用总结001---版本匹配问题unknown document format for file: E:\apache-tomcat-8.5.23\webapps\ZcnsDms\
    查看>>
    views
    查看>>
    OpenPPL PPQ量化(2):离线静态量化 源码剖析
    查看>>
    OpenPPL PPQ量化(3):量化计算图的加载和预处理 源码剖析
    查看>>
    OpenPPL PPQ量化(4):计算图的切分和调度 源码剖析
    查看>>
    OpenPPL PPQ量化(5):执行引擎 源码剖析
    查看>>
    openpyxl 模块的使用
    查看>>
    OpenResty & Nginx:详细对比与部署指南
    查看>>
    openresty 前端开发入门六之调试篇
    查看>>
    OpenResty(nginx扩展)实现防cc攻击
    查看>>
    openresty完美替代nginx
    查看>>
    Openresty框架入门详解
    查看>>