animation.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Page({
  2. onShareAppMessage() {
  3. return {
  4. title: '动画',
  5. path: 'page/API/pages/animation/animation'
  6. }
  7. },
  8. onReady() {
  9. this.animation = wx.createAnimation()
  10. },
  11. rotate() {
  12. this.animation.rotate(Math.random() * 720 - 360).step()
  13. this.setData({animation: this.animation.export()})
  14. },
  15. scale() {
  16. this.animation.scale(Math.random() * 2).step()
  17. this.setData({animation: this.animation.export()})
  18. },
  19. translate() {
  20. this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
  21. this.setData({animation: this.animation.export()})
  22. },
  23. skew() {
  24. this.animation.skew(Math.random() * 90, Math.random() * 90).step()
  25. this.setData({animation: this.animation.export()})
  26. },
  27. rotateAndScale() {
  28. this.animation.rotate(Math.random() * 720 - 360)
  29. .scale(Math.random() * 2)
  30. .step()
  31. this.setData({animation: this.animation.export()})
  32. },
  33. rotateThenScale() {
  34. this.animation.rotate(Math.random() * 720 - 360).step()
  35. .scale(Math.random() * 2).step()
  36. this.setData({animation: this.animation.export()})
  37. },
  38. all() {
  39. this.animation.rotate(Math.random() * 720 - 360)
  40. .scale(Math.random() * 2)
  41. .translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
  42. .skew(Math.random() * 90, Math.random() * 90)
  43. .step()
  44. this.setData({animation: this.animation.export()})
  45. },
  46. allInQueue() {
  47. this.animation.rotate(Math.random() * 720 - 360).step()
  48. .scale(Math.random() * 2).step()
  49. .translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
  50. .step()
  51. .skew(Math.random() * 90, Math.random() * 90)
  52. .step()
  53. this.setData({animation: this.animation.export()})
  54. },
  55. reset() {
  56. this.animation.rotate(0, 0)
  57. .scale(1)
  58. .translate(0, 0)
  59. .skew(0, 0)
  60. .step({duration: 0})
  61. this.setData({animation: this.animation.export()})
  62. }
  63. })