target.js 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // compontents/target/target.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. wxObjectives: {
  8. type: String,
  9. value: ""
  10. }
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. flag: false,
  17. animationData: {}
  18. },
  19. /**
  20. * 组件的方法列表
  21. */
  22. methods: {
  23. onTap (e) {
  24. let flage = e.target.dataset.flag;
  25. if(flage){
  26. this.util(flage, '156rpx');
  27. this.setData({'flag': false})
  28. } else {
  29. this.util(flage, '200rpx');
  30. this.setData({'flag': true})
  31. }
  32. },
  33. /* 创建动画并执行 */
  34. util (flag, height) {
  35. // 创建动画实例
  36. var animation = wx.createAnimation({
  37. duration: 200, //动画时长
  38. timingFunction: "linear", //线性
  39. delay: 0 //0则不延迟
  40. });
  41. this.animation = animation;
  42. animation.height(height).step();
  43. this.setData({
  44. animationData: animation.export()
  45. })
  46. }
  47. }
  48. })