Fix: calculate size dynamically
This commit is contained in:
parent
c5bcdd8f75
commit
71db6c7481
|
@ -133,16 +133,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* popup */
|
/* popup */
|
||||||
#stylus-popup #message-box {
|
#message-box.stylus-popup {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
#stylus-popup #message-box > div {
|
#message-box.stylus-popup > div {
|
||||||
max-width: 90vh;
|
max-width: 90vw;
|
||||||
top: auto;
|
top: auto;
|
||||||
right: auto;
|
right: auto;
|
||||||
}
|
}
|
||||||
|
#message-box.calculate-size {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
#message-box.calculate-size > div {
|
||||||
|
max-width: none;
|
||||||
|
max-height: none;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes fadein {
|
@keyframes fadein {
|
||||||
from {
|
from {
|
||||||
|
|
|
@ -11,13 +11,20 @@ function messageBox({
|
||||||
initOwnListeners();
|
initOwnListeners();
|
||||||
bindGlobalListeners();
|
bindGlobalListeners();
|
||||||
createElement();
|
createElement();
|
||||||
|
document.body.appendChild(messageBox.element);
|
||||||
if (location.href.includes('popup.html')) {
|
if (location.href.includes('popup.html')) {
|
||||||
|
messageBox.element.classList.add('stylus-popup');
|
||||||
|
|
||||||
|
// calculate size
|
||||||
|
messageBox.element.classList.add('calculate-size');
|
||||||
|
const {offsetWidth, offsetHeight} = messageBox.element.children[0];
|
||||||
|
messageBox.element.classList.remove('calculate-size');
|
||||||
|
|
||||||
messageBox.bodyWidth = document.body.style.width;
|
messageBox.bodyWidth = document.body.style.width;
|
||||||
messageBox.bodyHeight = document.body.style.height;
|
messageBox.bodyHeight = document.body.style.height;
|
||||||
document.body.style.width = '400px';
|
document.body.style.width = `${offsetWidth / 0.9}px`;
|
||||||
document.body.style.height = '600px';
|
document.body.style.height = `${offsetHeight / 0.9}px`;
|
||||||
}
|
}
|
||||||
document.body.appendChild(messageBox.element);
|
|
||||||
if (onshow) {
|
if (onshow) {
|
||||||
onshow(messageBox.element);
|
onshow(messageBox.element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user