@dolphinweex/weex-harmony 0.1.90 → 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
|
@@ -215,15 +215,18 @@ export default {
|
|
|
215
215
|
|
|
216
216
|
children.forEach((child, index) => {
|
|
217
217
|
const rect = child.getBoundingClientRect();
|
|
218
|
-
|
|
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,
|
|
221
|
-
minTop = Math.min(minTop,
|
|
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
|
-
//
|
|
229
|
+
// 优先使用相对坐标计算高度,不受视口滚动或容器偏移影响
|
|
227
230
|
let height = (maxBottom > minTop) ? (maxBottom - minTop) : 0;
|
|
228
231
|
|
|
229
232
|
this.debugLog(`计算高度详情: rectHeight=${height}, totalOffsetHeight=${totalOffsetHeight}, parentRectTop=${parentRect.top}`);
|
|
@@ -350,43 +353,24 @@ export default {
|
|
|
350
353
|
this.debugLog(`计算得到elementHeight=${elementHeight}px`);
|
|
351
354
|
|
|
352
355
|
if (elementHeight > 0) {
|
|
353
|
-
//
|
|
354
|
-
//
|
|
356
|
+
// isPluginMenu=false:始终不按视口裁剪,保持原逻辑不变。
|
|
357
|
+
// isPluginMenu=true:改为不裁剪,避免多组件时下方 iframe 被裁成一条线、且裁剪值同步到父级压扁整块。
|
|
355
358
|
let maxHeight = Number.POSITIVE_INFINITY;
|
|
356
|
-
this.debugLog(`初始maxHeight=${maxHeight}px (isPluginMenu=${this.isPluginMenu})`);
|
|
357
|
-
|
|
358
359
|
if (this.isPluginMenu) {
|
|
359
|
-
maxHeight =
|
|
360
|
-
if (this.$refs.iframe) {
|
|
361
|
-
try {
|
|
362
|
-
const rect = this.$refs.iframe.getBoundingClientRect();
|
|
363
|
-
this.debugLog(`iframe位置: top=${rect.top}, left=${rect.left}, width=${rect.width}, height=${rect.height}`);
|
|
364
|
-
if (rect.top > 0) {
|
|
365
|
-
maxHeight = window.innerHeight - rect.top;
|
|
366
|
-
this.debugLog(`plugin-menu 调整后maxHeight=${maxHeight}px (top=${rect.top})`);
|
|
367
|
-
}
|
|
368
|
-
} catch (e) {
|
|
369
|
-
this.debugWarn('获取 iframe 位置失败:', e);
|
|
370
|
-
}
|
|
371
|
-
} else {
|
|
372
|
-
this.debugWarn(`this.$refs.iframe 不存在`);
|
|
373
|
-
}
|
|
374
|
-
maxHeight = Math.max(maxHeight, 0);
|
|
360
|
+
maxHeight = Number.POSITIVE_INFINITY; // 仅对 plugin-menu 取消视口裁剪,不影响 isPluginMenu=false
|
|
375
361
|
}
|
|
376
|
-
|
|
377
|
-
this.debugLog(`最终maxHeight=${maxHeight}px`);
|
|
362
|
+
this.debugLog(`maxHeight=${maxHeight} (isPluginMenu=${this.isPluginMenu})`);
|
|
378
363
|
|
|
379
|
-
// 非 plugin-menu 不裁剪;plugin-menu 才按 maxHeight 限制
|
|
380
364
|
const finalHeight = elementHeight > maxHeight ? maxHeight : elementHeight;
|
|
381
|
-
this.debugLog(`finalHeight=${finalHeight}px (
|
|
365
|
+
this.debugLog(`finalHeight=${finalHeight}px (elementHeight=${elementHeight}, maxHeight=${maxHeight})`);
|
|
382
366
|
|
|
383
367
|
// 更新 iframe 高度(考虑 weex scale)
|
|
384
368
|
const scale = weex.config.env.scale || 1;
|
|
385
369
|
let newHeightValue = finalHeight / scale;
|
|
386
370
|
|
|
387
371
|
// 父级有 style 设置的高度时:若 iframe 计算高度偏小,直接用父级高度
|
|
388
|
-
//
|
|
389
|
-
//
|
|
372
|
+
// 关键:直接解析 inline style 字符串(rem/px),而不用 getBoundingClientRect,
|
|
373
|
+
// 避免因为内容撑大或旧代码写入导致取到错误的"当前渲染高度"
|
|
390
374
|
if (this._wrapperEl) {
|
|
391
375
|
try {
|
|
392
376
|
const inlineHeight = this._wrapperEl.style && this._wrapperEl.style.height;
|
|
@@ -411,7 +395,7 @@ export default {
|
|
|
411
395
|
this.debugLog(`计算newHeight=${newHeight} (finalHeight=${finalHeight}, scale=${scale}), 当前height=${this.height}`);
|
|
412
396
|
if (this.height !== newHeight) {
|
|
413
397
|
this.height = newHeight;
|
|
414
|
-
this.debugLog(`✅ iframe 高度已更新: ${finalHeight}px -> ${newHeight} (embedId: ${this.embedId}
|
|
398
|
+
this.debugLog(`✅ iframe 高度已更新: ${finalHeight}px -> ${newHeight} (embedId: ${this.embedId})`);
|
|
415
399
|
} else {
|
|
416
400
|
this.debugLog(`⚠️ 高度未变化,不更新 (当前=${this.height}, 新值=${newHeight})`);
|
|
417
401
|
}
|