Skip to content

Commit

Permalink
Lightbox: Fix close button position. (#56125)
Browse files Browse the repository at this point in the history
* use width 100%

* remove scroll bar width

* refactor

* use documentElement
  • Loading branch information
torounit authored Nov 16, 2023
1 parent 397320e commit dc17d94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
left: 0;
z-index: 100000;
overflow: hidden;
width: 100vw;
width: 100%;
height: 100vh;
box-sizing: border-box;
visibility: hidden;
Expand Down Expand Up @@ -372,7 +372,7 @@

@keyframes lightbox-zoom-in {
0% {
transform: translate(calc(-50vw + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
transform: translate(calc((-100vw + var(--wp--lightbox-scrollbar-width)) / 2 + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
}
100% {
transform: translate(-50%, -50%) scale(1, 1);
Expand All @@ -389,6 +389,6 @@
}
100% {
visibility: hidden;
transform: translate(calc(-50vw + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
transform: translate(calc((-100vw + var(--wp--lightbox-scrollbar-width)) / 2 + var(--wp--lightbox-initial-left-position)), calc(-50vh + var(--wp--lightbox-initial-top-position))) scale(var(--wp--lightbox-scale));
}
}
3 changes: 3 additions & 0 deletions packages/block-library/src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ function setStyles( context, ref ) {
--wp--lightbox-image-width: ${ lightboxImgWidth }px;
--wp--lightbox-image-height: ${ lightboxImgHeight }px;
--wp--lightbox-scale: ${ containerScale };
--wp--lightbox-scrollbar-width: ${
window.innerWidth - document.documentElement.clientWidth
}px;
}
`;
}
Expand Down

0 comments on commit dc17d94

Please sign in to comment.