util.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getMotion = getMotion;
  6. exports.getPlacementStyle = getPlacementStyle;
  7. function getPlacementStyle(placement, top, bottom) {
  8. let style;
  9. top = typeof top === 'number' ? `${top}px` : top;
  10. bottom = typeof bottom === 'number' ? `${bottom}px` : bottom;
  11. switch (placement) {
  12. case 'top':
  13. style = {
  14. left: '50%',
  15. transform: 'translateX(-50%)',
  16. right: 'auto',
  17. top,
  18. bottom: 'auto'
  19. };
  20. break;
  21. case 'topLeft':
  22. style = {
  23. left: 0,
  24. top,
  25. bottom: 'auto'
  26. };
  27. break;
  28. case 'topRight':
  29. style = {
  30. right: 0,
  31. top,
  32. bottom: 'auto'
  33. };
  34. break;
  35. case 'bottom':
  36. style = {
  37. left: '50%',
  38. transform: 'translateX(-50%)',
  39. right: 'auto',
  40. top: 'auto',
  41. bottom
  42. };
  43. break;
  44. case 'bottomLeft':
  45. style = {
  46. left: 0,
  47. top: 'auto',
  48. bottom
  49. };
  50. break;
  51. default:
  52. style = {
  53. right: 0,
  54. top: 'auto',
  55. bottom
  56. };
  57. break;
  58. }
  59. return style;
  60. }
  61. function getMotion(prefixCls) {
  62. return {
  63. name: `${prefixCls}-fade`
  64. };
  65. }