WXML

  1. <view class="container">
  2. <view class="page-body">
  3. <view class="page-section">
  4.  
  5. <view class="animation-element-wrapper">
  6. <view class="animation-element" animation="{{animation}}"></view>
  7. </view>
  8. <scroll-view class="animation-buttons" scroll-y="true">
  9. <button class="animation-button" bindtap="rotate">旋转</button>
  10. <button class="animation-button" bindtap="scale">缩放</button>
  11. <button class="animation-button" bindtap="translate">移动</button>
  12. <button class="animation-button" bindtap="skew">倾斜</button>
  13. <button class="animation-button" bindtap="rotateAndScale">旋转并缩放</button>
  14. <button class="animation-button" bindtap="rotateThenScale">旋转后缩放</button>
  15. <button class="animation-button" bindtap="all">同时展示全部</button>
  16. <button class="animation-button" bindtap="allInQueue">顺序展示全部</button>
  17. <button class="animation-button animation-button-reset" bindtap="reset">还原</button>
  18. </scroll-view>
  19. </view>
  20. </view>
  21. </view>

WXSS:

  1. .animation-element-wrapper {
  2. display: flex;
  3. width: %;
  4. padding-top: 150rpx;
  5. padding-bottom: 150rpx;
  6. justify-content: center;
  7. overflow: hidden;
  8. background-color: #ffffff;
  9. }
  10. .animation-element {
  11. width: 200rpx;
  12. height: 200rpx;
  13. background-color: #1AAD19;
  14. }
  15. .animation-buttons {
  16. padding: 30rpx 50rpx 10rpx;
  17. width: %;
  18. height: 600rpx;
  19. box-sizing: border-box;
  20. }
  21. .animation-button {
  22. float: left;
  23. line-height: ;
  24. width: 300rpx;
  25. margin: 15rpx 12rpx;
  26. }
  27.  
  28. .animation-button-reset {
  29. width: 620rpx;
  30. }

JS:

  1. Page({
  2. onReady: function () {
  3. this.animation = wx.createAnimation()
  4. },
  5. rotate: function () {
  6. this.animation.rotate(Math.random() * - ).step()
  7. this.setData({ animation: this.animation.export() })
  8. },
  9. scale: function () {
  10. this.animation.scale(Math.random() * ).step()
  11. this.setData({ animation: this.animation.export() })
  12. },
  13. translate: function () {
  14. this.animation.translate(Math.random() * - , Math.random() * - ).step()
  15. this.setData({ animation: this.animation.export() })
  16. },
  17. skew: function () {
  18. this.animation.skew(Math.random() * , Math.random() * ).step()
  19. this.setData({ animation: this.animation.export() })
  20. },
  21. rotateAndScale: function () {
  22. this.animation.rotate(Math.random() * - )
  23. .scale(Math.random() * )
  24. .step()
  25. this.setData({ animation: this.animation.export() })
  26. },
  27. rotateThenScale: function () {
  28. this.animation.rotate(Math.random() * - ).step()
  29. .scale(Math.random() * ).step()
  30. this.setData({ animation: this.animation.export() })
  31. },
  32. all: function () {
  33. this.animation.rotate(Math.random() * - )
  34. .scale(Math.random() * )
  35. .translate(Math.random() * - , Math.random() * - )
  36. .skew(Math.random() * , Math.random() * )
  37. .step()
  38. this.setData({ animation: this.animation.export() })
  39. },
  40. allInQueue: function () {
  41. this.animation.rotate(Math.random() * - ).step()
  42. .scale(Math.random() * ).step()
  43. .translate(Math.random() * - , Math.random() * - ).step()
  44. .skew(Math.random() * , Math.random() * ).step()
  45. this.setData({ animation: this.animation.export() })
  46. },
  47. reset: function () {
  48. this.animation.rotate(, )
  49. .scale()
  50. .translate(, )
  51. .skew(, )
  52. .step({ duration: })
  53. this.setData({ animation: this.animation.export() })
  54. }
  55. })

小程序animation动画效果(小程序组件案例)的更多相关文章

  1. 小程序animation动画效果综合应用案例(交流QQ群:604788754)

    如果案例有问题,可到QQ群找到今日相关压缩文件下载测试. WXML: <view class="cebian"> <view animation="{{ ...

  2. Android中xml设置Animation动画效果详解

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  3. android中设置Animation 动画效果

    在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...

  4. 模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果)

    模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果) 效果图: 切图地址: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zg ...

  5. 微信小程序Animation动画的使用

    目录 1,前言 2,属性 3,使用 1,前言 和css3动画不同,小程序中动画是主要是通过js控制的,简单来说就是创建一个动画实例animation.调用实例的方法来定义动画效果.最后通过动画实例的e ...

  6. 微信小程序的动画效果

    前言 由于公司计划有变,所以从H5页面改成去小程序写.所以在着手开发小程序.本人也不是什么前端高手,只是一名写后端偶尔写写前端的渣渣.请前端大神们勿喷. 一.什么是微信小程序? 小程序在我的理解中只是 ...

  7. 微信小程序animation动画2种方法

    这里介绍 2 种方法一种是常规的小程序方法操作,另一种是引入动画库 1. 常规动画操作设置 wxml: <view> <view bindtap="clickMe" ...

  8. android Animation 动画效果介绍

    Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动 ...

  9. ios animation 动画效果实现

    1.过渡动画 CATransition CATransition *animation = [CATransition animation]; [animation setDuration:1.0]; ...

随机推荐

  1. 车载项目问题解(memset)

    1memset函数解 1.void *memset(void *s,int c,size_t n) 总的作用:将已开辟内存空间 s 的首 n 个字节的值设为值 c.2.例子 #includevoid ...

  2. poj 2481 Cows(树状数组)题解

    Description Farmer John's cows have discovered that the clover growing along the ridge of the hill ( ...

  3. IntelliJ-IDEA和Git、GitHub、Gitlab的使用

    一.基本入门 1.IntelliJ-IDEA预装的版本控制介绍 我们来看IntelliJ-IDEA的版本控制设置区域 打开File>Settings>Version Control  可以 ...

  4. BZOJ1726: [Usaco2006 Nov]Roadblocks第二短路 K短路

    Description 贝茜把家搬到了一个小农场,但她常常回到FJ的农场去拜访她的朋友.贝茜很喜欢路边的风景,不想那么快地结束她的旅途,于是她每次回农场,都会选择第二短的路径,而不象我们所习惯的那样, ...

  5. 论文笔记——Channel Pruning for Accelerating Very Deep Neural Networks

    论文地址:https://arxiv.org/abs/1707.06168 代码地址:https://github.com/yihui-he/channel-pruning 采用方法 这篇文章主要讲诉 ...

  6. 联想笔记本thinkpad按F2不能直接重命名

    联想笔记本thinkpad按F2不能直接重命名,而是Fn+F2. 解决: 按一下Fn+Esc(一般在左上角)

  7. java反射基础

    转载请注明出处:https://i.cnblogs.com/EditPosts.aspx?opt=1最近在接触到框架的底层的时候,遇到了反射,便想好好的学习和总结一下反射,帮助理解java框架的运行流 ...

  8. Java中的RTTI

    RTTI可以帮助我们在运行时识别对象和类的信息. 一般传统的RTTI有三种实现方式: 1. 向上转型或向下转型(upcasting and downcasting),在java中,向下转型(父类转成子 ...

  9. SQLServer中获取所有数据库名、所有表名、所有字段名的SQL语句

    ----1. 获取所有的数据库名----- SELECT NAME FROM MASTER.DBO.SYSDATABASES ORDER BY NAME -----2. 获取所有的表名------ S ...

  10. 《A_Pancers团队》———团队项目原型设计与开发

    一.实验目的与要求 (1)掌握软件原型开发技术: (2)学习使用软件原型开发工具:本实验中使用墨刀 二.实验内容与步骤 任务1:针对实验六团队项目选题,采用适当的原型开发工具设计团队项目原型: 任务2 ...