小程序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]; ...
随机推荐
- 车载项目问题解(memset)
1memset函数解 1.void *memset(void *s,int c,size_t n) 总的作用:将已开辟内存空间 s 的首 n 个字节的值设为值 c.2.例子 #includevoid ...
- poj 2481 Cows(树状数组)题解
Description Farmer John's cows have discovered that the clover growing along the ridge of the hill ( ...
- IntelliJ-IDEA和Git、GitHub、Gitlab的使用
一.基本入门 1.IntelliJ-IDEA预装的版本控制介绍 我们来看IntelliJ-IDEA的版本控制设置区域 打开File>Settings>Version Control 可以 ...
- BZOJ1726: [Usaco2006 Nov]Roadblocks第二短路 K短路
Description 贝茜把家搬到了一个小农场,但她常常回到FJ的农场去拜访她的朋友.贝茜很喜欢路边的风景,不想那么快地结束她的旅途,于是她每次回农场,都会选择第二短的路径,而不象我们所习惯的那样, ...
- 论文笔记——Channel Pruning for Accelerating Very Deep Neural Networks
论文地址:https://arxiv.org/abs/1707.06168 代码地址:https://github.com/yihui-he/channel-pruning 采用方法 这篇文章主要讲诉 ...
- 联想笔记本thinkpad按F2不能直接重命名
联想笔记本thinkpad按F2不能直接重命名,而是Fn+F2. 解决: 按一下Fn+Esc(一般在左上角)
- java反射基础
转载请注明出处:https://i.cnblogs.com/EditPosts.aspx?opt=1最近在接触到框架的底层的时候,遇到了反射,便想好好的学习和总结一下反射,帮助理解java框架的运行流 ...
- Java中的RTTI
RTTI可以帮助我们在运行时识别对象和类的信息. 一般传统的RTTI有三种实现方式: 1. 向上转型或向下转型(upcasting and downcasting),在java中,向下转型(父类转成子 ...
- SQLServer中获取所有数据库名、所有表名、所有字段名的SQL语句
----1. 获取所有的数据库名----- SELECT NAME FROM MASTER.DBO.SYSDATABASES ORDER BY NAME -----2. 获取所有的表名------ S ...
- 《A_Pancers团队》———团队项目原型设计与开发
一.实验目的与要求 (1)掌握软件原型开发技术: (2)学习使用软件原型开发工具:本实验中使用墨刀 二.实验内容与步骤 任务1:针对实验六团队项目选题,采用适当的原型开发工具设计团队项目原型: 任务2 ...