Browse Source

BI-118917 fix: bi.switcher这种利用Masker遮罩的场景处理

research/test
zsmj 2 years ago
parent
commit
aab95e8e2a
  1. 61
      src/core/controller/controller.layer.js
  2. 14
      src/core/platform/web/dom.js

61
src/core/controller/controller.layer.js

@ -63,41 +63,54 @@ BI.LayerController = BI.inherit(BI.Controller, {
var layout = BI.createWidget({
type: "bi.absolute",
invisible: true,
items: [{
el: widget,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
items: [
{
el: widget,
left: 0,
right: 0,
top: 0,
bottom: 0
}
]
}, context);
BI.createWidget({
type: "bi.absolute",
element: op.container || this.options.render,
items: [{
el: layout,
left: offset.left || 0,
right: offset.right || 0,
top: offset.top || 0,
bottom: offset.bottom || 0
}]
items: [
{
el: layout,
left: offset.left || 0,
right: offset.right || 0,
top: offset.top || 0,
bottom: offset.bottom || 0
}
]
});
if (w) {
layout.element.addClass("bi-popup-view");
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css({
function getComputedPosition() {
var css = {
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
width: offset.width || (w.outerWidth() - (offset.left || 0) - (offset.right || 0)) || "",
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || ""
});
};
const { top, left, scaleY, scaleX } = BI.DOM.getPositionRelativeContainingBlockRect(layout.element[0]);
css.top = (css.top - top) / scaleY;
css.left = (css.left - left) / scaleX;
return css;
}
layout.element.css(getComputedPosition());
layout.element.on("__resize__", function () {
w.is(":visible") &&
layout.element.css(getComputedPosition());
});
}
this.add(name, widget, layout);

14
src/core/platform/web/dom.js

@ -732,5 +732,19 @@
return BI.DOM.getPositionRelativeContainingBlock(element.parentNode);
},
/**
* 获取position:fixed相对定位的元素的clientRect
*/
getPositionRelativeContainingBlockRect: function (element) {
var positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock(element);
var rect = positionRelativeElement.getBoundingClientRect();
return {
...rect.toJSON(),
scaleX: rect.width / positionRelativeElement.offsetWidth,
scaleY: rect.height / positionRelativeElement.offsetHeight
};
},
});
})();

Loading…
Cancel
Save