Strict verification of itemFocalPoint variable as undefined.

This commit is contained in:
Mateus Machado Luna 2019-11-21 11:45:08 -03:00
parent f1e4b661b7
commit 6cce09ce7e
1 changed files with 5 additions and 5 deletions

View File

@ -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'
}}
>
<a
@ -416,7 +416,7 @@ registerBlockType('tainacan/dynamic-items-list', {
}
function updateMosaicItemFocalPoint(focalPoint) {
if (Math.abs(focalPoint.x - mosaicItemFocalPoint.x) > 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 }