rc-new-window
Advanced tools
Comparing version 0.1.1 to 0.1.2
import React from 'react'; | ||
interface Feature { | ||
width?: number; | ||
height?: number; | ||
left?: number; | ||
top?: number; | ||
} | ||
interface Props { | ||
@@ -9,4 +15,4 @@ children?: React.ReactNode; | ||
height?: number; | ||
left?: number; | ||
top?: number; | ||
initPopupInnerRect?: () => Feature; | ||
initPopupOuterRect?: () => Feature; | ||
onOpen?: (w: Window) => void; | ||
@@ -25,2 +31,3 @@ onClose?: () => void; | ||
declare class NewWindow extends React.PureComponent<Props, State> { | ||
static supported: boolean; | ||
/** | ||
@@ -27,0 +34,0 @@ * NewWindow default props. |
"use strict"; | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
@@ -24,2 +25,4 @@ import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
var BrowserPopupWindow_1 = require("./BrowserPopupWindow"); | ||
var onNewWindowResize = debounce_1.default(function () { | ||
@@ -122,11 +125,9 @@ // add/remove element on main document, force it to dispatch resize observer event on the popup window | ||
name = _this$props.name, | ||
left = _this$props.left, | ||
top = _this$props.top, | ||
width = _this$props.width, | ||
height = _this$props.height, | ||
initPopupInnerRect = _this$props.initPopupInnerRect, | ||
initPopupOuterRect = _this$props.initPopupOuterRect, | ||
onBlock = _this$props.onBlock, | ||
onOpen = _this$props.onOpen; | ||
var features = { | ||
left: left, | ||
top: top, | ||
width: width, | ||
@@ -136,3 +137,22 @@ height: height | ||
if (left == null || top == null) { | ||
if (initPopupOuterRect) { | ||
features = initPopupOuterRect(); | ||
var _BrowserPopupWindow_ = _slicedToArray(BrowserPopupWindow_1.popupWindowBorder, 3), | ||
topBorder = _BrowserPopupWindow_[0], | ||
sideBorder = _BrowserPopupWindow_[1], | ||
bottomBorder = _BrowserPopupWindow_[2]; | ||
features.width -= sideBorder * 2; | ||
features.height -= topBorder + bottomBorder; | ||
} else if (initPopupInnerRect) { | ||
features = initPopupInnerRect(); | ||
var _BrowserPopupWindow_2 = _slicedToArray(BrowserPopupWindow_1.popupWindowBorder, 2), | ||
_topBorder = _BrowserPopupWindow_2[0], | ||
_sideBorder = _BrowserPopupWindow_2[1]; | ||
features.left -= _sideBorder; | ||
features.top -= _topBorder; | ||
} else { | ||
features.left = window.top.outerWidth / 2 + window.top.screenX - width / 2; | ||
@@ -188,2 +208,4 @@ features.top = window.top.outerHeight / 2 + window.top.screenY - height / 2; | ||
}(react_1.default.PureComponent); | ||
NewWindow.supported = BrowserPopupWindow_1.popupSupported; | ||
/** | ||
@@ -193,3 +215,2 @@ * NewWindow default props. | ||
NewWindow.defaultProps = { | ||
@@ -196,0 +217,0 @@ url: '', |
import React from 'react'; | ||
interface Feature { | ||
width?: number; | ||
height?: number; | ||
left?: number; | ||
top?: number; | ||
} | ||
interface Props { | ||
@@ -9,4 +15,4 @@ children?: React.ReactNode; | ||
height?: number; | ||
left?: number; | ||
top?: number; | ||
initPopupInnerRect?: () => Feature; | ||
initPopupOuterRect?: () => Feature; | ||
onOpen?: (w: Window) => void; | ||
@@ -25,2 +31,3 @@ onClose?: () => void; | ||
declare class NewWindow extends React.PureComponent<Props, State> { | ||
static supported: boolean; | ||
/** | ||
@@ -27,0 +34,0 @@ * NewWindow default props. |
@@ -5,2 +5,4 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -30,2 +32,4 @@ | ||
var BrowserPopupWindow_1 = require("./BrowserPopupWindow"); | ||
var onNewWindowResize = debounce_1.default(function () { | ||
@@ -127,11 +131,9 @@ // add/remove element on main document, force it to dispatch resize observer event on the popup window | ||
name = _this$props.name, | ||
left = _this$props.left, | ||
top = _this$props.top, | ||
width = _this$props.width, | ||
height = _this$props.height, | ||
initPopupInnerRect = _this$props.initPopupInnerRect, | ||
initPopupOuterRect = _this$props.initPopupOuterRect, | ||
onBlock = _this$props.onBlock, | ||
onOpen = _this$props.onOpen; | ||
var features = { | ||
left: left, | ||
top: top, | ||
width: width, | ||
@@ -141,3 +143,22 @@ height: height | ||
if (left == null || top == null) { | ||
if (initPopupOuterRect) { | ||
features = initPopupOuterRect(); | ||
var _BrowserPopupWindow_ = (0, _slicedToArray2.default)(BrowserPopupWindow_1.popupWindowBorder, 3), | ||
topBorder = _BrowserPopupWindow_[0], | ||
sideBorder = _BrowserPopupWindow_[1], | ||
bottomBorder = _BrowserPopupWindow_[2]; | ||
features.width -= sideBorder * 2; | ||
features.height -= topBorder + bottomBorder; | ||
} else if (initPopupInnerRect) { | ||
features = initPopupInnerRect(); | ||
var _BrowserPopupWindow_2 = (0, _slicedToArray2.default)(BrowserPopupWindow_1.popupWindowBorder, 2), | ||
_topBorder = _BrowserPopupWindow_2[0], | ||
_sideBorder = _BrowserPopupWindow_2[1]; | ||
features.left -= _sideBorder; | ||
features.top -= _topBorder; | ||
} else { | ||
features.left = window.top.outerWidth / 2 + window.top.screenX - width / 2; | ||
@@ -192,2 +213,4 @@ features.top = window.top.outerHeight / 2 + window.top.screenY - height / 2; | ||
}(react_1.default.PureComponent); | ||
NewWindow.supported = BrowserPopupWindow_1.popupSupported; | ||
/** | ||
@@ -197,3 +220,2 @@ * NewWindow default props. | ||
NewWindow.defaultProps = { | ||
@@ -200,0 +222,0 @@ url: '', |
{ | ||
"name": "rc-new-window", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "popup new browser window with react", | ||
@@ -42,2 +42,3 @@ "keywords": [ | ||
"@babel/runtime": "^7.10.1", | ||
"bowser": "^2.11.0", | ||
"classnames": "2.x", | ||
@@ -44,0 +45,0 @@ "lodash": "^4.17.20" |
@@ -99,8 +99,14 @@ # rc-new-window | ||
<tr> | ||
<td>left</td> | ||
<td>Number</td> | ||
<td>center of current window</td> | ||
<td>Window position</td> | ||
<td>initPopupInnerRect</td> | ||
<td>Function</td> | ||
<td></td> | ||
<td>init the window client area<br/>return {left,top,width,height}</td> | ||
</tr> | ||
<tr> | ||
<td>initPopupOuterRect</td> | ||
<td>Function</td> | ||
<td></td> | ||
<td>init the window position and size<br/>return {left,top,width,height}</td> | ||
</tr> | ||
<tr> | ||
<td>top</td> | ||
@@ -107,0 +113,0 @@ <td>Number</td> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44663
15
1202
141
6
+ Addedbowser@^2.11.0
+ Addedbowser@2.11.0(transitive)