animation.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Page({
  2. onReady() {
  3. this.animation = my.createAnimation()
  4. },
  5. rotate() {
  6. this.animation.rotate(Math.random() * 720 - 360).step()
  7. this.setData({ animation: this.animation.export() })
  8. },
  9. scale() {
  10. this.animation.scale(Math.random() * 2).step()
  11. this.setData({ animation: this.animation.export() })
  12. },
  13. translate() {
  14. this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
  15. this.setData({ animation: this.animation.export() })
  16. },
  17. skew() {
  18. this.animation.skew(Math.random() * 90, Math.random() * 90).step()
  19. this.setData({ animation: this.animation.export() })
  20. },
  21. rotateAndScale() {
  22. this.animation.rotate(Math.random() * 720 - 360)
  23. .scale(Math.random() * 2)
  24. .step()
  25. this.setData({ animation: this.animation.export() })
  26. },
  27. rotateThenScale() {
  28. this.animation.rotate(Math.random() * 720 - 360).step()
  29. .scale(Math.random() * 2).step()
  30. this.setData({ animation: this.animation.export() })
  31. },
  32. all() {
  33. this.animation.rotate(Math.random() * 720 - 360)
  34. .scale(Math.random() * 2)
  35. .translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
  36. .skew(Math.random() * 90, Math.random() * 90)
  37. .step()
  38. this.setData({ animation: this.animation.export() })
  39. },
  40. allInQueue() {
  41. this.animation.rotate(Math.random() * 720 - 360).step()
  42. .scale(Math.random() * 2).step()
  43. .translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
  44. .skew(Math.random() * 90, Math.random() * 90).step()
  45. this.setData({ animation: this.animation.export() })
  46. },
  47. reset() {
  48. this.animation.rotate3d(0, 0, 0)
  49. .scale(1)
  50. .translate(0, 0)
  51. .skew(0, 0)
  52. .step({ duration: 0 })
  53. this.setData({ animation: this.animation.export() })
  54. }
  55. })