微信小程序开发——动画效果

<view style='width:60px;height:60px;background-color:yellow;' animation="{{moveData}}" bindtap='moveClick'>移动</view>
 
<view style='width:60px;height:60px;background-color:red;' animation="{{rotateData}}" bindtap='rotateClick'>旋转</view>
 
<view style='width:60px;height:60px;background-color:green;' animation="{{alphaData}}" bindtap='alphaClick'>透明度</view>
 
<view style='width:60px;height:60px;background-color:orange;' animation="{{scaleData}}" bindtap='scaleClick'>缩放</view>
 
<view style='width:60px;height:60px;background-color:blue;' animation="{{skewData}}" bindtap='skewClick'>倾斜</view>
 
<view style='width:60px;height:60px;background-color:black;color:white' animation="{{matrixData}}" bindtap='matrixClick'>变形</view>
 
<view style='width:60px;height:60px;background-color:yellow;' animation="{{queueData}}" bindtap='queueClick'>移动\n变小\n透明</view>
 

 

Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    widthScreen:null,
    moveData:null,
    rotateData:null,
    alphaData:null,
    scaleData:null,
    skewData:null,
    matrixData:null
  },
 
  moveClick: function(){
    var animation = wx.createAnimation({
      duration: 3000,
      delay: 0,
      timingFunction: "ease",
    });
    
    animation.translate((this.data.widthScreen - 60), 0).step({duration: 3000})
    this.setData({moveData: animation.export()})
  },
 
  rotateClick: function(even) {
    var animation = wx.createAnimation({})
    animation.rotate(180).step({duration:3000})
    this.setData({rotateData: animation.export()})
  },
 
  alphaClick: function(even) {
    var animation = wx.createAnimation({})
    animation.opacity(0.1).step({duration: 2000})
    this.setData({alphaData: animation.export()})
  },
  
  scaleClick: function(even) {
    var animation = wx.createAnimation({})
    animation.scale(1.6).step({duration: 2000})
    this.setData({scaleData: animation.export()})
  },
  
  skewClick: function(even) {
    var animation = wx.createAnimation({})
    animation.skew(160).step({duration: 2000})
    this.setData({skewData: animation.export()})
  },
  
  matrixClick: function(even) {
    var animation = wx.createAnimation({})
    animation.matrix(1,3,4,5,2,2).step({ duration: 2000 })
    this.setData({ matrixData: animation.export() })
  },
  
  queueClick: function() {
    var animation = wx.createAnimation({});
    animation.translate((this.data.widthScreen - 60), 0).scale(0.3).opacity(0.5).step({duration: 3000})
    this.setData({queueData: animation.export() })
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取屏蔽宽
    var thisBlock = this;
    wx.getSystemInfo({
      success: function(res) {
        thisBlock.setData({
          widthScreen: res.screenWidth
        })
      },
    })
  }
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值