小程序animation动画效果(小程序组件案例)
WXML
<view class="container">
<view class="page-body">
<view class="page-section"> <view class="animation-element-wrapper">
<view class="animation-element" animation="{{animation}}"></view>
</view>
<scroll-view class="animation-buttons" scroll-y="true">
<button class="animation-button" bindtap="rotate">旋转</button>
<button class="animation-button" bindtap="scale">缩放</button>
<button class="animation-button" bindtap="translate">移动</button>
<button class="animation-button" bindtap="skew">倾斜</button>
<button class="animation-button" bindtap="rotateAndScale">旋转并缩放</button>
<button class="animation-button" bindtap="rotateThenScale">旋转后缩放</button>
<button class="animation-button" bindtap="all">同时展示全部</button>
<button class="animation-button" bindtap="allInQueue">顺序展示全部</button>
<button class="animation-button animation-button-reset" bindtap="reset">还原</button>
</scroll-view>
</view>
</view>
</view>
WXSS:
.animation-element-wrapper {
display: flex;
width: %;
padding-top: 150rpx;
padding-bottom: 150rpx;
justify-content: center;
overflow: hidden;
background-color: #ffffff;
}
.animation-element {
width: 200rpx;
height: 200rpx;
background-color: #1AAD19;
}
.animation-buttons {
padding: 30rpx 50rpx 10rpx;
width: %;
height: 600rpx;
box-sizing: border-box;
}
.animation-button {
float: left;
line-height: ;
width: 300rpx;
margin: 15rpx 12rpx;
}
.animation-button-reset {
width: 620rpx;
}
JS:
Page({
onReady: function () {
this.animation = wx.createAnimation()
},
rotate: function () {
this.animation.rotate(Math.random() * - ).step()
this.setData({ animation: this.animation.export() })
},
scale: function () {
this.animation.scale(Math.random() * ).step()
this.setData({ animation: this.animation.export() })
},
translate: function () {
this.animation.translate(Math.random() * - , Math.random() * - ).step()
this.setData({ animation: this.animation.export() })
},
skew: function () {
this.animation.skew(Math.random() * , Math.random() * ).step()
this.setData({ animation: this.animation.export() })
},
rotateAndScale: function () {
this.animation.rotate(Math.random() * - )
.scale(Math.random() * )
.step()
this.setData({ animation: this.animation.export() })
},
rotateThenScale: function () {
this.animation.rotate(Math.random() * - ).step()
.scale(Math.random() * ).step()
this.setData({ animation: this.animation.export() })
},
all: function () {
this.animation.rotate(Math.random() * - )
.scale(Math.random() * )
.translate(Math.random() * - , Math.random() * - )
.skew(Math.random() * , Math.random() * )
.step()
this.setData({ animation: this.animation.export() })
},
allInQueue: function () {
this.animation.rotate(Math.random() * - ).step()
.scale(Math.random() * ).step()
.translate(Math.random() * - , Math.random() * - ).step()
.skew(Math.random() * , Math.random() * ).step()
this.setData({ animation: this.animation.export() })
},
reset: function () {
this.animation.rotate(, )
.scale()
.translate(, )
.skew(, )
.step({ duration: })
this.setData({ animation: this.animation.export() })
}
})
小程序animation动画效果(小程序组件案例)的更多相关文章
- 小程序animation动画效果综合应用案例(交流QQ群:604788754)
如果案例有问题,可到QQ群找到今日相关压缩文件下载测试. WXML: <view class="cebian"> <view animation="{{ ...
- Android中xml设置Animation动画效果详解
在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...
- android中设置Animation 动画效果
在 Android 中, Animation 动画效果的实现可以通过两种方式进行实现,一种是 tweened animation 渐变动画,另一种是 frame by frame animation ...
- 模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果)
模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果) 效果图: 切图地址: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zg ...
- 微信小程序Animation动画的使用
目录 1,前言 2,属性 3,使用 1,前言 和css3动画不同,小程序中动画是主要是通过js控制的,简单来说就是创建一个动画实例animation.调用实例的方法来定义动画效果.最后通过动画实例的e ...
- 微信小程序的动画效果
前言 由于公司计划有变,所以从H5页面改成去小程序写.所以在着手开发小程序.本人也不是什么前端高手,只是一名写后端偶尔写写前端的渣渣.请前端大神们勿喷. 一.什么是微信小程序? 小程序在我的理解中只是 ...
- 微信小程序animation动画2种方法
这里介绍 2 种方法一种是常规的小程序方法操作,另一种是引入动画库 1. 常规动画操作设置 wxml: <view> <view bindtap="clickMe" ...
- android Animation 动画效果介绍
Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动 ...
- ios animation 动画效果实现
1.过渡动画 CATransition CATransition *animation = [CATransition animation]; [animation setDuration:1.0]; ...
随机推荐
- Android实践项目汇报总结(上)修改
微博客户端的设计与实现(上) 第一章 绪论 1.1课题背景 微博可以说是时下最受人们所喜爱的一种社交方式,它是一种通过关注机制分享简短实时信息的广播式的社交网络平台.通过微博我们可以了解最新的时事新闻 ...
- 基于Android应用《玩转英语》(总报告)
基于Android应用<玩转英语> 摘 要 ...
- WideCharToMultiByte和MultiByteToWideChar函数的用法(转载)
出处:http://www.cnblogs.com/gakusei/articles/1585211.html 为了支持Unicode编码,需要多字节与宽字节之间的相互转换.这两个系统函数在使用时需要 ...
- 设置控件如ImageButton可见与否
继承view的控件有三种ui属性: 1.setVisibility(View.Gone); 不可见,不占有空间 2.setVisibility(View.VISIBLE); 可见 3.setVisib ...
- 让低版本浏览器支持html5的标签
原理就是首先用js的createElement来创建,之后在使用 document.createElement('header'); <header> <hgroup>头部信息 ...
- 软件设计师真题试题&&答案
软件设计师2013上半年上午试题及答案详解 下午试题 2013下半年上午答案 试题 下午答案 试题 2014上半年上午答案 2015上半年上午答案 2016上半年上午试题
- js渐隐渐现透明度变化淡入淡出轮播图
js渐隐渐现透明度变化淡入淡出轮播图.焦点图 一些广告banner展示常见. (附件) <!DOCTYPE html> <html> <head> <meta ...
- string 和 wstring
区别: char* wchar_t 一个字节 两个字节 ACSII编码 unicode编码 转换: 1.Windows API WideCharToMultiByte() MultiByteToWid ...
- 用docker部署gitlab
docker hub官网下载gitlab速度太慢,改用国内镜像+中文版 docker pull registry.cn-hangzhou.aliyuncs.com/lab99/gitlab-ce-zh ...
- Unity中使用的一套敏感词过滤方式
当项目中的敏感词数量不是很多的时候,直接用数组来遍历过滤其实也可以,但是具体的数量有多大,这个肯定不好说,因此,对.txt中的敏感词合理组织后再进行过滤就显得非常有必要了. 如上图,左边是txt中配置 ...