utils.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends2 = require('babel-runtime/helpers/extends');
  6. var _extends3 = _interopRequireDefault(_extends2);
  7. exports.getAlignFromPlacement = getAlignFromPlacement;
  8. exports.getAlignPopupClassName = getAlignPopupClassName;
  9. exports.noop = noop;
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11. function isPointsEq(a1, a2, isAlignPoint) {
  12. if (isAlignPoint) {
  13. return a1[0] === a2[0];
  14. }
  15. return a1[0] === a2[0] && a1[1] === a2[1];
  16. }
  17. function getAlignFromPlacement(builtinPlacements, placementStr, align) {
  18. var baseAlign = builtinPlacements[placementStr] || {};
  19. return (0, _extends3['default'])({}, baseAlign, align);
  20. }
  21. function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
  22. var points = align.points;
  23. for (var placement in builtinPlacements) {
  24. if (builtinPlacements.hasOwnProperty(placement)) {
  25. if (isPointsEq(builtinPlacements[placement].points, points, isAlignPoint)) {
  26. return prefixCls + '-placement-' + placement;
  27. }
  28. }
  29. }
  30. return '';
  31. }
  32. function noop() {}