diff --git a/src/gutenberg-blocks/tainacan-items/dynamic-items-list/index.js b/src/gutenberg-blocks/tainacan-items/dynamic-items-list/index.js index f8ce6763d..263a26e13 100644 --- a/src/gutenberg-blocks/tainacan-items/dynamic-items-list/index.js +++ b/src/gutenberg-blocks/tainacan-items/dynamic-items-list/index.js @@ -132,7 +132,7 @@ registerBlockType('tainacan/dynamic-items-list', { type: String, default: '' }, - mosaicItemFocalPoint: { + osaicItemFocalPointm: { type: Object, default: { x: 0.5, @@ -190,7 +190,7 @@ registerBlockType('tainacan/dynamic-items-list', { style={ { marginBottom: layout == 'grid' ? (showName ? gridMargin + 12 : gridMargin) + 'px' : '', backgroundImage: layout == 'mosaic' ? `url(${getItemThumbnail(item, 'medium_large')})` : 'none', - backgroundPosition: layout == 'mosaic' ? `${ mosaicItemFocalPoint.x * 100 }% ${ mosaicItemFocalPoint.y * 100 }%` : 'none' + backgroundPosition: layout == 'mosaic' ? `${ (mosaicItemFocalPoint && mosaicItemFocalPoint.x ? mosaicItemFocalPoint.x : 0.5) * 100 }% ${ (mosaicItemFocalPoint && mosaicItemFocalPoint.y ? mosaicItemFocalPoint.y : 0.5) * 100 }%` : 'none' }} > 0.025 || Math.abs(focalPoint.y - mosaicItemFocalPoint.y) > 0.025) { + if (Math.abs(focalPoint.x - (mosaicItemFocalPoint && mosaicItemFocalPoint.x ? mosaicItemFocalPoint.x : 0.5)) > 0.025 || Math.abs(focalPoint.y - (mosaicItemFocalPoint && mosaicItemFocalPoint.y ? mosaicItemFocalPoint.y : 0.5)) > 0.025) { mosaicItemFocalPoint = focalPoint; setAttributes({ mosaicItemFocalPoint: focalPoint }); setContent(); @@ -1000,8 +1000,8 @@ registerBlockType('tainacan/dynamic-items-list', { mosaic-density={ mosaicDensity } mosaic-grid-rows={ mosaicGridRows } mosaic-grid-columns={ mosaicGridColumns } - mosaic-item-focal-point-x={ mosaicItemFocalPoint.x } - mosaic-item-focal-point-y={ mosaicItemFocalPoint.y } + mosaic-item-focal-point-x={ (mosaicItemFocalPoint && mosaicItemFocalPoint.x ? mosaicItemFocalPoint.x : 0.5) } + mosaic-item-focal-point-y={ (mosaicItemFocalPoint && mosaicItemFocalPoint.y ? mosaicItemFocalPoint.y : 0.5) } collection-background-color={ collectionBackgroundColor } collection-text-color={ collectionTextColor } grid-margin={ gridMargin }