@rc-component/trigger 1.15.3 → 1.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,17 +106,31 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
106
106
  // ========================= Align =========================
107
107
  var onAlign = useEvent(function () {
108
108
  if (popupEle && target && open) {
109
+ var _popupElement$parentE, _popupElement$parentE2;
109
110
  var popupElement = popupEle;
111
+ var doc = popupElement.ownerDocument;
112
+ var win = getWin(popupElement);
113
+ var _win$getComputedStyle = win.getComputedStyle(popupElement),
114
+ width = _win$getComputedStyle.width,
115
+ height = _win$getComputedStyle.height,
116
+ popupPosition = _win$getComputedStyle.position;
110
117
  var originLeft = popupElement.style.left;
111
118
  var originTop = popupElement.style.top;
112
119
  var originRight = popupElement.style.right;
113
120
  var originBottom = popupElement.style.bottom;
114
- var doc = popupElement.ownerDocument;
115
- var win = getWin(popupElement);
116
121
 
117
122
  // Placement
118
123
  var placementInfo = _objectSpread(_objectSpread({}, builtinPlacements[placement]), popupAlign);
119
124
 
125
+ // placeholder element
126
+ var placeholderElement = doc.createElement('div');
127
+ (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 ? void 0 : _popupElement$parentE.appendChild(placeholderElement);
128
+ placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
129
+ placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
130
+ placeholderElement.style.position = popupPosition;
131
+ placeholderElement.style.height = "".concat(popupElement.offsetHeight, "px");
132
+ placeholderElement.style.width = "".concat(popupElement.offsetWidth, "px");
133
+
120
134
  // Reset first
121
135
  popupElement.style.left = '0';
122
136
  popupElement.style.top = '0';
@@ -142,9 +156,6 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
142
156
  };
143
157
  }
144
158
  var popupRect = popupElement.getBoundingClientRect();
145
- var _win$getComputedStyle = win.getComputedStyle(popupElement),
146
- width = _win$getComputedStyle.width,
147
- height = _win$getComputedStyle.height;
148
159
  var _doc$documentElement = doc.documentElement,
149
160
  clientWidth = _doc$documentElement.clientWidth,
150
161
  clientHeight = _doc$documentElement.clientHeight,
@@ -197,6 +208,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
197
208
  popupElement.style.top = originTop;
198
209
  popupElement.style.right = originRight;
199
210
  popupElement.style.bottom = originBottom;
211
+ (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 ? void 0 : _popupElement$parentE2.removeChild(placeholderElement);
200
212
 
201
213
  // Calculate scale
202
214
  var _scaleX = toNum(Math.round(popupWidth / parseFloat(width) * 1000) / 1000);
@@ -114,17 +114,31 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
114
114
  // ========================= Align =========================
115
115
  var onAlign = (0, _useEvent.default)(function () {
116
116
  if (popupEle && target && open) {
117
+ var _popupElement$parentE, _popupElement$parentE2;
117
118
  var popupElement = popupEle;
119
+ var doc = popupElement.ownerDocument;
120
+ var win = (0, _util.getWin)(popupElement);
121
+ var _win$getComputedStyle = win.getComputedStyle(popupElement),
122
+ width = _win$getComputedStyle.width,
123
+ height = _win$getComputedStyle.height,
124
+ popupPosition = _win$getComputedStyle.position;
118
125
  var originLeft = popupElement.style.left;
119
126
  var originTop = popupElement.style.top;
120
127
  var originRight = popupElement.style.right;
121
128
  var originBottom = popupElement.style.bottom;
122
- var doc = popupElement.ownerDocument;
123
- var win = (0, _util.getWin)(popupElement);
124
129
 
125
130
  // Placement
126
131
  var placementInfo = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, builtinPlacements[placement]), popupAlign);
127
132
 
133
+ // placeholder element
134
+ var placeholderElement = doc.createElement('div');
135
+ (_popupElement$parentE = popupElement.parentElement) === null || _popupElement$parentE === void 0 ? void 0 : _popupElement$parentE.appendChild(placeholderElement);
136
+ placeholderElement.style.left = "".concat(popupElement.offsetLeft, "px");
137
+ placeholderElement.style.top = "".concat(popupElement.offsetTop, "px");
138
+ placeholderElement.style.position = popupPosition;
139
+ placeholderElement.style.height = "".concat(popupElement.offsetHeight, "px");
140
+ placeholderElement.style.width = "".concat(popupElement.offsetWidth, "px");
141
+
128
142
  // Reset first
129
143
  popupElement.style.left = '0';
130
144
  popupElement.style.top = '0';
@@ -150,9 +164,6 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
150
164
  };
151
165
  }
152
166
  var popupRect = popupElement.getBoundingClientRect();
153
- var _win$getComputedStyle = win.getComputedStyle(popupElement),
154
- width = _win$getComputedStyle.width,
155
- height = _win$getComputedStyle.height;
156
167
  var _doc$documentElement = doc.documentElement,
157
168
  clientWidth = _doc$documentElement.clientWidth,
158
169
  clientHeight = _doc$documentElement.clientHeight,
@@ -205,6 +216,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
205
216
  popupElement.style.top = originTop;
206
217
  popupElement.style.right = originRight;
207
218
  popupElement.style.bottom = originBottom;
219
+ (_popupElement$parentE2 = popupElement.parentElement) === null || _popupElement$parentE2 === void 0 ? void 0 : _popupElement$parentE2.removeChild(placeholderElement);
208
220
 
209
221
  // Calculate scale
210
222
  var _scaleX = (0, _util.toNum)(Math.round(popupWidth / parseFloat(width) * 1000) / 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"