animate.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.setContentAnimate = void 0;
  4. var utils_1 = require("../common/utils");
  5. function useAnimation(context, expanded, mounted, height) {
  6. var animation = wx.createAnimation({
  7. duration: 0,
  8. timingFunction: 'ease-in-out',
  9. });
  10. if (expanded) {
  11. if (height === 0) {
  12. animation.height('auto').top(1).step();
  13. }
  14. else {
  15. animation
  16. .height(height)
  17. .top(1)
  18. .step({
  19. duration: mounted ? 300 : 1,
  20. })
  21. .height('auto')
  22. .step();
  23. }
  24. context.setData({
  25. animation: animation.export(),
  26. });
  27. return;
  28. }
  29. animation.height(height).top(0).step({ duration: 1 }).height(0).step({
  30. duration: 300,
  31. });
  32. context.setData({
  33. animation: animation.export(),
  34. });
  35. }
  36. function setContentAnimate(context, expanded, mounted) {
  37. (0, utils_1.getRect)(context, '.van-collapse-item__content')
  38. .then(function (rect) { return rect.height; })
  39. .then(function (height) {
  40. useAnimation(context, expanded, mounted, height);
  41. });
  42. }
  43. exports.setContentAnimate = setContentAnimate;