Skip to content

Commit

Permalink
Only show visualizer while resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Oct 25, 2022
1 parent 45b73ef commit f3fce3d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default function Image( {
setLoadedNaturalSize,
] = useState( {} );
const [ isEditingImage, setIsEditingImage ] = useState( false );
const [ isResizingImage, setIsResizingImage ] = useState( false );
const [ externalBlob, setExternalBlob ] = useState();
const clientWidth = useClientWidth( containerRef, [ align ] );
const isResizable =
Expand Down Expand Up @@ -233,10 +234,12 @@ export default function Image( {

function onResizeStart() {
toggleSelection( false );
setIsResizingImage( true );
}

function onResizeStop() {
toggleSelection( true );
setIsResizingImage( false );
}

function onImageError() {
Expand Down Expand Up @@ -584,11 +587,13 @@ export default function Image( {

img = (
<>
<AlignmentVisualizer
clientId={ clientId }
allowedAlignments={ [ 'none', 'wide', 'full' ] }
value={ align }
/>
{ isResizingImage && (
<AlignmentVisualizer
clientId={ clientId }
allowedAlignments={ [ 'none', 'wide', 'full' ] }
value={ align }
/>
) }
<ResizableBox
size={ {
width: width ?? 'auto',
Expand Down

0 comments on commit f3fce3d

Please sign in to comment.