index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Tencent is pleased to support the open source community by making Face-2-Face Translator available.
  3. Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
  4. Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  5. http://opensource.org/licenses/MIT
  6. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  7. */
  8. Component({
  9. properties: {
  10. },
  11. data: {
  12. waiting_animation: {},
  13. waiting_animation_1: {},
  14. },
  15. ready: function () {
  16. console.log("ready waitting")
  17. this.waiting_animation = wx.createAnimation({
  18. duration: 600
  19. })
  20. this.waiting_animation_1 = wx.createAnimation({
  21. duration: 400
  22. })
  23. this.setWaitInterval()
  24. },
  25. // 组件生命周期函数,在组件实例被从页面节点树移除时执行
  26. detached: function() {
  27. this.clearAnimation()
  28. },
  29. methods: {
  30. clearAnimation: function() {
  31. this.endWaitAnimation()
  32. },
  33. /**
  34. * 清除动画
  35. */
  36. endWaitAnimation: function() {
  37. clearInterval(this.data.waiting_interval)
  38. this.setData({ waiting_animation : {}})
  39. this.setData({ waiting_animation_1: {} })
  40. },
  41. startWaitAnimation: function () {
  42. this.waiting_animation.opacity(0).scale(1.2, 1.2).step()
  43. this.waiting_animation.opacity(1).scale(1, 1).step()
  44. this.setData({ waiting_animation: this.waiting_animation.export() })
  45. this.waiting_animation_1.opacity(0).scale(1.2, 1.2).step()
  46. this.waiting_animation_1.opacity(1).scale(1, 1).step()
  47. this.setData({ waiting_animation_1: this.waiting_animation_1.export() })
  48. },
  49. /**
  50. * 设置动画
  51. */
  52. setWaitInterval: function() {
  53. this.endWaitAnimation()
  54. this.data.waiting_interval = setInterval( ()=>{
  55. this.startWaitAnimation()
  56. },600 )
  57. },
  58. }
  59. });