Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

BootstrapModalManager.js 2.7 KiB

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
  2. import css from 'dom-helpers/css';
  3. import qsa from 'dom-helpers/querySelectorAll';
  4. import getScrollbarSize from 'dom-helpers/scrollbarSize';
  5. import ModalManager from 'react-overlays/ModalManager';
  6. var Selector = {
  7. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  8. STICKY_CONTENT: '.sticky-top',
  9. NAVBAR_TOGGLER: '.navbar-toggler'
  10. };
  11. var BootstrapModalManager = /*#__PURE__*/function (_ModalManager) {
  12. _inheritsLoose(BootstrapModalManager, _ModalManager);
  13. function BootstrapModalManager() {
  14. var _this;
  15. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  16. args[_key] = arguments[_key];
  17. }
  18. _this = _ModalManager.call.apply(_ModalManager, [this].concat(args)) || this;
  19. _this.adjustAndStore = function (prop, element, adjust) {
  20. var _css;
  21. var actual = element.style[prop];
  22. element.dataset[prop] = actual;
  23. css(element, (_css = {}, _css[prop] = parseFloat(css(element, prop)) + adjust + "px", _css));
  24. };
  25. _this.restore = function (prop, element) {
  26. var value = element.dataset[prop];
  27. if (value !== undefined) {
  28. var _css2;
  29. delete element.dataset[prop];
  30. css(element, (_css2 = {}, _css2[prop] = value, _css2));
  31. }
  32. };
  33. return _this;
  34. }
  35. var _proto = BootstrapModalManager.prototype;
  36. _proto.setContainerStyle = function setContainerStyle(containerState, container) {
  37. var _this2 = this;
  38. _ModalManager.prototype.setContainerStyle.call(this, containerState, container);
  39. if (!containerState.overflowing) return;
  40. var size = getScrollbarSize();
  41. qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
  42. return _this2.adjustAndStore('paddingRight', el, size);
  43. });
  44. qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
  45. return _this2.adjustAndStore('margingRight', el, -size);
  46. });
  47. qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
  48. return _this2.adjustAndStore('margingRight', el, size);
  49. });
  50. };
  51. _proto.removeContainerStyle = function removeContainerStyle(containerState, container) {
  52. var _this3 = this;
  53. _ModalManager.prototype.removeContainerStyle.call(this, containerState, container);
  54. qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
  55. return _this3.restore('paddingRight', el);
  56. });
  57. qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
  58. return _this3.restore('margingRight', el);
  59. });
  60. qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
  61. return _this3.restore('margingRight', el);
  62. });
  63. };
  64. return BootstrapModalManager;
  65. }(ModalManager);
  66. export { BootstrapModalManager as default };