lessonList.js 1019 B

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