Skip to content

Commit

Permalink
fix: layout jump on modal open
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Jul 12, 2024
1 parent e0f7475 commit d2867e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function createModal(html, className, onclose, canclose) {
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
document.body.style.transform = `translateX(${scrollbarWidth}px)`;
let modal = document.createElement('div');
modal.classList.add('modal');
let modal_content = document.createElement('div');
Expand All @@ -26,8 +28,8 @@ function createModal(html, className, onclose, canclose) {
close.classList.add('modal-close');
close.title = "ESC";
close.innerHTML = '×';
document.body.style.overflowY = 'hidden';
function removeModal() {
document.body.style.transform = ``;
modal.remove();
let event = new Event('findActiveTweet');
document.dispatchEvent(event);
Expand Down Expand Up @@ -61,6 +63,7 @@ function createModal(html, className, onclose, canclose) {
document.addEventListener('keydown', escapeEvent);
modal_content.appendChild(close);
document.body.appendChild(modal);
document.body.style.transform = ``
return modal;
}
async function handleFiles(files, mediaArray, mediaContainer, is_dm = false) {
Expand Down

0 comments on commit d2867e9

Please sign in to comment.