Answer the question
In order to leave comments, you need to log in
How to center modal window BX.PopupWindow?
The page has a component - a modal window. The form is located not at the beginning, but at the bottom of the page. Because of this, there were problems with the location of the modal window.
If you set the value offsetTop: window.pageYOffset, then the modal window opens too low, close to the footer. And if 0, then it opens at the very beginning of the page. I need the window to open in the center of the page at its current position.
<script>
BX.ready(function(){
var m_popup = BX.PopupWindowManager.create('sender_subscribe_component', window.body, {
autoHide: true,
width: 320,
offsetTop: window.pageYOffset,
offsetLeft: (document.body.clientWidth - 400)/2,
lightShadow: true,
closeIcon: true,
closeByEsc: true,
overlay: {
backgroundColor: 'rgba(0,0,0,0.82)', opacity: '80', width: '100%'
}
});
m_popup.setContent(BX('sender-subscribe-response-cont'));
m_popup.show();
});
</script>
Answer the question
In order to leave comments, you need to log in
You can center a popup using its adjustPosition and resizeOverlay methods;
For example like this:
var popup = BX.PopupWindowManager.create("sender_subscribe_component", null, {
autoHide: true,
offsetLeft: 0,
offsetTop: 0,
overlay: true,
closeByEsc: true,
events: {
onAfterPopupShow: function () {
popup.adjustPosition();
popup.resizeOverlay();
}
}
});
popup.show();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question