1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
- import qsa from 'dom-helpers/query/querySelectorAll';
- import css from 'dom-helpers/style';
- import getScrollbarSize from 'dom-helpers/util/scrollbarSize';
- import ModalManager from 'react-overlays/ModalManager';
- var Selector = {
- FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
- STICKY_CONTENT: '.sticky-top',
- NAVBAR_TOGGLER: '.navbar-toggler'
- };
-
- var BootstrapModalManager =
- /*#__PURE__*/
- function (_ModalManager) {
- _inheritsLoose(BootstrapModalManager, _ModalManager);
-
- function BootstrapModalManager() {
- var _this;
-
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- _this = _ModalManager.call.apply(_ModalManager, [this].concat(args)) || this;
-
- _this.adjustAndStore = function (prop, element, adjust) {
- var actual = element.style[prop];
- element.dataset[prop] = actual;
- css(element, prop, parseFloat(css(element, prop)) + adjust + "px");
- };
-
- _this.restore = function (prop, element) {
- var value = element.dataset[prop];
-
- if (value !== undefined) {
- delete element.dataset[prop];
- css(element, prop, value);
- }
- };
-
- return _this;
- }
-
- var _proto = BootstrapModalManager.prototype;
-
- _proto.setContainerStyle = function setContainerStyle(containerState, container) {
- var _this2 = this;
-
- _ModalManager.prototype.setContainerStyle.call(this, containerState, container);
-
- if (!containerState.overflowing) return;
- var size = getScrollbarSize();
- qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
- return _this2.adjustAndStore('paddingRight', el, size);
- });
- qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
- return _this2.adjustAndStore('margingRight', el, -size);
- });
- qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
- return _this2.adjustAndStore('margingRight', el, size);
- });
- };
-
- _proto.removeContainerStyle = function removeContainerStyle(containerState, container) {
- var _this3 = this;
-
- _ModalManager.prototype.removeContainerStyle.call(this, containerState, container);
-
- qsa(container, Selector.FIXED_CONTENT).forEach(function (el) {
- return _this3.restore('paddingRight', el);
- });
- qsa(container, Selector.STICKY_CONTENT).forEach(function (el) {
- return _this3.restore('margingRight', el);
- });
- qsa(container, Selector.NAVBAR_TOGGLER).forEach(function (el) {
- return _this3.restore('margingRight', el);
- });
- };
-
- return BootstrapModalManager;
- }(ModalManager);
-
- export { BootstrapModalManager as default };
|