index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import ad from '../index/ad'
  2. ad({
  3. data: {
  4. animations: [
  5. 'fadeIn',
  6. 'fadeInDown',
  7. 'fadeInLeft',
  8. 'fadeInRight',
  9. 'fadeInUp',
  10. 'slideInUp',
  11. 'slideInDown',
  12. 'slideInLeft',
  13. 'slideInRight',
  14. 'zoom',
  15. 'punch',
  16. 'custom',
  17. ],
  18. example: {
  19. animation: 'fadeIn',
  20. classNames: 'wux-animate--fadeIn',
  21. enter: true,
  22. exit: true,
  23. in: false,
  24. },
  25. },
  26. onClick(e) {
  27. const { index } = e.currentTarget.dataset
  28. const animation = this.data.animations[index]
  29. const classNames = `wux-animate--${animation}`
  30. this.setData({
  31. 'example.in': true,
  32. 'example.classNames': classNames,
  33. 'example.animation': animation,
  34. })
  35. },
  36. onEnter(e) {
  37. console.log('onEnter', e.detail)
  38. },
  39. onEntering(e) {
  40. console.log('onEntering', e.detail)
  41. },
  42. onEntered(e) {
  43. console.log('onEntered', e.detail)
  44. // delay 300ms close animation
  45. setTimeout(() => this.setData({ 'example.in': false }), 300)
  46. },
  47. onExit() {
  48. console.log('onExit')
  49. },
  50. onExiting() {
  51. console.log('onExiting')
  52. },
  53. onExited() {
  54. console.log('onExited')
  55. },
  56. onChange(e) {
  57. console.log('onChange', e.detail)
  58. },
  59. })