无遮无挡三级动态图,熟女人妻高清一区二区三区,午夜精品一区二区三区 ,色吧成人网,无码爆乳护士让我爽

注冊

微信小程序API動畫,wx.createAnimation創(chuàng)建一個動畫實(shí)例

2020-09-27
導(dǎo)讀:wx.createAnimation(OBJECT) ? 創(chuàng)建一個動畫實(shí)例animation。調(diào)用實(shí)例的方法來描述動畫。最后通過動畫實(shí)例的 export 方法導(dǎo)出動畫數(shù)據(jù)傳遞給組件的 animation 屬性。 注意: export 方法每次調(diào)用后會...

wx.createAnimation(OBJECT)

微信小程序API動畫,wx.createAnimation創(chuàng)建一個動畫實(shí)例


? 創(chuàng)建一個動畫實(shí)例animation。調(diào)用實(shí)例的方法來描述動畫。最后通過動畫實(shí)例的export方法導(dǎo)出動畫數(shù)據(jù)傳遞給組件的animation屬性。

注意:export方法每次調(diào)用后會清掉之前的動畫操作

OBJECT參數(shù)說明:

 

參數(shù) 類型 必填 默認(rèn)值 說明
duration Integer 400 動畫持續(xù)時間,單位ms
timingFunction String "linear" 定義動畫的效果
delay Integer 0 動畫延遲時間,單位 ms
transformOrigin String "50% 50% 0" 設(shè)置transform-origin

 

timingFunction 有效值:

說明
linear 動畫從頭到尾的速度是相同的
ease 動畫以低速開始,然后加快,在結(jié)束前變慢
ease-in 動畫以低速開始
ease-in-out 動畫以低速開始和結(jié)束
ease-out 動畫以低速結(jié)束
step-start 動畫第一幀就跳至結(jié)束狀態(tài)直到結(jié)束
step-end 動畫一直保持開始狀態(tài),最后一幀跳到結(jié)束狀態(tài)

var animation = wx.createAnimation({
  transformOrigin:"50% 50%",
  duration:1000,
  timingFunction:"ease",
  delay:0
})

animation


動畫實(shí)例可以調(diào)用以下方法來描述動畫,調(diào)用結(jié)束后會返回自身,支持鏈?zhǔn)秸{(diào)用的寫法。

animation 對象的方法列表:

樣式:

方法 參數(shù) 說明
opacity value 透明度,參數(shù)范圍 0~1
backgroundColor color 顏色值
width length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值
height length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值
top length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值
left length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值
bottom length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值
right length 長度值,如果傳入 Number 則默認(rèn)使用 px,可傳入其他自定義單位的長度值

旋轉(zhuǎn):

方法 參數(shù) 說明
rotate deg deg的范圍-180~180,從原點(diǎn)順時針旋轉(zhuǎn)一個deg角度
rotateX deg deg的范圍-180~180,在X軸旋轉(zhuǎn)一個deg角度
rotateY deg deg的范圍-180~180,在Y軸旋轉(zhuǎn)一個deg角度
rotateZ deg deg的范圍-180~180,在Z軸旋轉(zhuǎn)一個deg角度
rotate3d (x,y,z,deg) 同transform-function rotate3d

縮放:

方法 參數(shù) 說明
scale sx,[sy] 一個參數(shù)時,表示在X軸、Y軸同時縮放sx倍數(shù);兩個參數(shù)時表示在X軸縮放sx倍數(shù),在Y軸縮放sy倍數(shù)
scaleX sx 在X軸縮放sx倍數(shù)
scaleY sy 在Y軸縮放sy倍數(shù)
scaleZ sz 在Z軸縮放sy倍數(shù)
scale3d (sx,sy,sz) 在X軸縮放sx倍數(shù),在Y軸縮放sy倍數(shù),在Z軸縮放sz倍數(shù)

偏移:

方法 參數(shù) 說明
translate tx,[ty] 一個參數(shù)時,表示在X軸偏移tx,單位px;兩個參數(shù)時,表示在X軸偏移tx,在Y軸偏移ty,單位px。
translateX tx 在X軸偏移tx,單位px
translateY ty 在Y軸偏移tx,單位px
translateZ tz 在Z軸偏移tx,單位px
translate3d (tx,ty,tz) 在X軸偏移tx,在Y軸偏移ty,在Z軸偏移tz,單位px

傾斜:

方法 參數(shù) 說明
skew ax,[ay] 參數(shù)范圍-180~180;一個參數(shù)時,Y軸坐標(biāo)不變,X軸坐標(biāo)延順時針傾斜ax度;兩個參數(shù)時,分別在X軸傾斜ax度,在Y軸傾斜ay度
skewX ax 參數(shù)范圍-180~180;Y軸坐標(biāo)不變,X軸坐標(biāo)延順時針傾斜ax度
skewY ay 參數(shù)范圍-180~180;X軸坐標(biāo)不變,Y軸坐標(biāo)延順時針傾斜ay度

矩陣變形:

方法 參數(shù) 說明
matrix (a,b,c,d,tx,ty) 同transform-function matrix
matrix3d   同transform-function matrix3d

動畫隊(duì)列


調(diào)用動畫操作方法后要調(diào)用step()來表示一組動畫完成,可以在一組動畫中調(diào)用任意多個動畫方法,一組動畫中的所有動畫會同時開始,一組動畫完成后才會進(jìn)行下一組動畫。step 可以傳入一個跟wx.createAnimation()一樣的配置參數(shù)用于指定當(dāng)前組動畫的配置。

示例:

<view animation="{{animationData}}" style="background:red,height:100rpx,width:100rpx"></view>
Page({
  data:{
    animationData:{}
  },
  onShow:function(){
    var animation = wx.createAnimation({
      duration:1000,
        timingFunction:"ease",
    })

    this.animation = animation

    animation.scale(2,2).rotate(45).step();

    this.setData({
      animationData:animation.export()
    })

    setTimeout(function(){
      animation.translate(30).step();
      this.setData({
        animationData:animation.export()
      })
    }.bind(this),1000)
  },
  rotateAndScale: function () {
    // 旋轉(zhuǎn)同時放大
    this.animation.rotate(45).scale(2, 2).step()
    this.setData({
      animationData:animation.export()
    })
  },
  rotateThenScale: function () {
    // 先旋轉(zhuǎn)后放大
    this.animation.rotate(45).step()
    this.animation.scale(2, 2).step()
    this.setData({
      animationData:animation.export()
    })
  },
  rotateAndScaleThenTranslate: function () {
    // 先旋轉(zhuǎn)同時放大,然后平移
    this.animation.rotate(45).scale(2, 2).step()
    this.animation.translate(100, 100).step({ duration: 1000 })
    this.setData({
      animationData:animation.export()
    })
  }
})

 

bug & tip

  1. bugiOS/Android6.3.30通過 step() 分隔動畫,只有第一步動畫能生效

 

更多微信小程序開發(fā)教程,可以關(guān)注hi小程序。
重磅推薦:小程序開店目錄

第一部分:小商店是什么

第二部分:如何開通一個小商店

第三部分:如何登錄小商店

第四部分:開店任務(wù)常見問題

第五部分:小商店可以賣什么

第六部分:HiShop小程序特色功能

第七部分:小程序直播

第八部分:小程序收貨/物流

第九部分:小程序怎么結(jié)算

第十部分:小程序客服

第十一部分:電商創(chuàng)業(yè)

第十二部分:小程序游戲開發(fā)