@dolphinweex/weex-harmony 0.1.91 → 0.1.92

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -215,15 +215,18 @@ export default {
215
215
 
216
216
  children.forEach((child, index) => {
217
217
  const rect = child.getBoundingClientRect();
218
- this.debugLog(`子级 ${index}: top=${rect.top}, bottom=${rect.bottom}, height=${rect.height}`);
218
+ // 转换为相对于父元素的坐标,避免视口绝对坐标中负 top 导致高度被持续放大
219
+ const relTop = rect.top - parentRect.top;
220
+ const relBottom = rect.bottom - parentRect.top;
221
+ this.debugLog(`子级 ${index}: top=${relTop}, bottom=${relBottom}, height=${rect.height}`);
219
222
  if (rect.height > 0) {
220
- maxBottom = Math.max(maxBottom, rect.bottom);
221
- minTop = Math.min(minTop, rect.top);
223
+ maxBottom = Math.max(maxBottom, relBottom);
224
+ minTop = Math.min(minTop, Math.max(0, relTop)); // 负偏移从0算起,不向上扩展
222
225
  }
223
226
  totalOffsetHeight += (child.offsetHeight || 0);
224
227
  });
225
228
 
226
- // 优先使用 getBoundingClientRect 计算出的相对高度
229
+ // 优先使用相对坐标计算高度,不受视口滚动或容器偏移影响
227
230
  let height = (maxBottom > minTop) ? (maxBottom - minTop) : 0;
228
231
 
229
232
  this.debugLog(`计算高度详情: rectHeight=${height}, totalOffsetHeight=${totalOffsetHeight}, parentRectTop=${parentRect.top}`);