|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
value: true
|
|
|
});
|
|
|
exports.default = void 0;
|
|
|
|
|
|
var _react = _interopRequireDefault(require("react"));
|
|
|
|
|
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
|
|
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
|
|
|
var _utils = require("./utils");
|
|
|
|
|
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
|
|
function _templateObject3() {
|
|
|
var data = _taggedTemplateLiteral(["\n animation: ", " 400ms ease;\n & > * {\n animation: ", " 400ms ease;\n opacity: ", ";\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n }\n"]);
|
|
|
|
|
|
_templateObject3 = function _templateObject3() {
|
|
|
return data;
|
|
|
};
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
function _templateObject2() {
|
|
|
var data = _taggedTemplateLiteral(["\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n transform: translateY(50px);\n }\n"]);
|
|
|
|
|
|
_templateObject2 = function _templateObject2() {
|
|
|
return data;
|
|
|
};
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
function _templateObject() {
|
|
|
var data = _taggedTemplateLiteral(["\n from {\n opacity: 0;\n transform: translateY(50px);\n }\n to {\n opacity: 1;\n }\n"]);
|
|
|
|
|
|
_templateObject = function _templateObject() {
|
|
|
return data;
|
|
|
};
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
|
|
|
|
var fadeInUp = (0, _styledComponents.keyframes)(_templateObject());
|
|
|
var fadeOutDown = (0, _styledComponents.keyframes)(_templateObject2());
|
|
|
var IframeWrapper = (0, _styledComponents.default)('div')(_templateObject3(), function (_ref) {
|
|
|
var visible = _ref.visible;
|
|
|
return visible ? fadeInUp : fadeOutDown;
|
|
|
}, function (_ref2) {
|
|
|
var visible = _ref2.visible;
|
|
|
return visible ? fadeInUp : fadeOutDown;
|
|
|
}, function (_ref3) {
|
|
|
var visible = _ref3.visible;
|
|
|
return visible ? 1 : 0;
|
|
|
});
|
|
|
|
|
|
var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
_inherits(Modal, _React$Component);
|
|
|
|
|
|
var _super = _createSuper(Modal);
|
|
|
|
|
|
function Modal() {
|
|
|
var _this;
|
|
|
|
|
|
_classCallCheck(this, Modal);
|
|
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
|
args[_key] = arguments[_key];
|
|
|
}
|
|
|
|
|
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
|
|
|
|
_this.switchScrollingEffect = function (close) {
|
|
|
var bodyIsOverflowing = document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth;
|
|
|
|
|
|
if (!bodyIsOverflowing) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (close) {
|
|
|
document.body.style.position = '';
|
|
|
document.body.style.width = '';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var scrollBarSize = (0, _utils.getScrollBarSize)();
|
|
|
|
|
|
if (scrollBarSize) {
|
|
|
document.body.style.position = 'relative';
|
|
|
document.body.style.width = "calc(100% - ".concat(scrollBarSize, "px)");
|
|
|
}
|
|
|
};
|
|
|
|
|
|
_this.addScrollingEffect = function () {
|
|
|
var node = _this.nodeDom;
|
|
|
|
|
|
_this.switchScrollingEffect();
|
|
|
|
|
|
document.body.style['overflow-y'] = 'hidden';
|
|
|
node.style.display = 'block';
|
|
|
requestAnimationFrame(function () {
|
|
|
node.style.opacity = '1';
|
|
|
});
|
|
|
};
|
|
|
|
|
|
_this.removeScrollingEffect = function () {
|
|
|
var node = _this.nodeDom;
|
|
|
document.body.style['overflow-y'] = '';
|
|
|
|
|
|
_this.switchScrollingEffect(true);
|
|
|
|
|
|
node.style.opacity = '0';
|
|
|
requestAnimationFrame(function () {
|
|
|
node.style.display = 'none';
|
|
|
});
|
|
|
};
|
|
|
|
|
|
return _this;
|
|
|
}
|
|
|
|
|
|
_createClass(Modal, [{
|
|
|
key: "componentDidMount",
|
|
|
value: function componentDidMount() {
|
|
|
// eslint-disable-next-line
|
|
|
this.nodeDom = _reactDom.default.findDOMNode(this); // DidMount 的时候就是true,因为默认是未定义。
|
|
|
// 所以强行调用一下 componentDidUpdate,可以防止闪动
|
|
|
|
|
|
this.componentDidUpdate();
|
|
|
}
|
|
|
}, {
|
|
|
key: "componentDidUpdate",
|
|
|
value: function componentDidUpdate() {
|
|
|
if (this.props.visible) {
|
|
|
this.addScrollingEffect();
|
|
|
} else {
|
|
|
this.removeScrollingEffect();
|
|
|
}
|
|
|
}
|
|
|
}, {
|
|
|
key: "render",
|
|
|
value: function render() {
|
|
|
var _this$props = this.props,
|
|
|
children = _this$props.children,
|
|
|
visible = _this$props.visible;
|
|
|
var style = {
|
|
|
position: 'absolute',
|
|
|
zIndex: 1001,
|
|
|
bottom: 72,
|
|
|
right: 0,
|
|
|
boxShadow: '0 4px 8px 0 rgba(13, 26, 38, 0.2)',
|
|
|
background: '#23232d',
|
|
|
width: '68vw',
|
|
|
height: '80vh'
|
|
|
};
|
|
|
return /*#__PURE__*/_react.default.createElement(IframeWrapper, {
|
|
|
style: style,
|
|
|
visible: visible
|
|
|
}, children);
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
return Modal;
|
|
|
}(_react.default.Component);
|
|
|
|
|
|
var _default = Modal;
|
|
|
exports.default = _default; |