diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 7bd7bf7c067f2d..af4c3dcacc1a1b 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -310,11 +310,11 @@ class="wp-lightbox-overlay zoom" - - + + - - + + diff --git a/packages/block-library/src/image/style.scss b/packages/block-library/src/image/style.scss index 4aa366fc31a2b8..779c12a584ec7e 100644 --- a/packages/block-library/src/image/style.scss +++ b/packages/block-library/src/image/style.scss @@ -227,6 +227,7 @@ .prev-button, .next-button { + display: none; position: absolute; top: 50%; transform: translateY(-50%); @@ -235,7 +236,6 @@ z-index: 5000000; min-width: 40px; // equivalent to $button-size-next-default-40px min-height: 40px; // equivalent to $button-size-next-default-40px; - display: flex; align-items: center; justify-content: center; @@ -243,12 +243,20 @@ display: none; } + &[disabled] { + opacity: 0.25; + } + &:hover, &:focus, &:not(:hover):not(:active):not(.has-background) { background: none; border: none; } + + @include break-mobile() { + display: flex; + } } .prev-button { diff --git a/packages/block-library/src/image/view.js b/packages/block-library/src/image/view.js index 4b027ba890434b..832b57a510b73c 100644 --- a/packages/block-library/src/image/view.js +++ b/packages/block-library/src/image/view.js @@ -34,6 +34,12 @@ const { state, actions, callbacks } = store( get currentImage() { return state.metadata[ state.currentImageId ]; }, + get hasNextImage() { + return state.currentImageIndex + 1 < state.images.length; + }, + get hasPreviousImage() { + return state.currentImageIndex - 1 >= 0; + }, get overlayOpened() { return state.currentImageId !== null; }, @@ -112,7 +118,6 @@ const { state, actions, callbacks } = store( // Sets the current expanded image in the state and enables the overlay. state.overlayEnabled = true; - state.currentImageId = imageId; // Computes the styles of the overlay for the animation. callbacks.setOverlayStyles(); @@ -366,7 +371,7 @@ const { state, actions, callbacks } = store( // the image resolution. let horizontalPadding = 0; if ( window.innerWidth > 480 ) { - horizontalPadding = 80; + horizontalPadding = state.isGallery ? 140 : 80; } else if ( window.innerWidth > 1920 ) { horizontalPadding = 160; }