Skip to content

Commit 5aebbc0

Browse files
committed
#25464: Applied code review suggestions
1 parent c657fb2 commit 5aebbc0

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ define([
2828
listens: {
2929
'${ $.provider }:params.filters': 'hide',
3030
'${ $.provider }:params.search': 'hide'
31+
},
32+
exports: {
33+
height: '${ $.parentName }.thumbnail_url:previewHeight'
3134
}
3235
},
3336

@@ -43,9 +46,6 @@ define([
4346
'displayedRecord',
4447
'lastOpenedImage'
4548
]);
46-
this.height.subscribe(function () {
47-
this.thumbnailComponent().previewHeight(this.height());
48-
}, this);
4949

5050
return this;
5151
},

app/code/Magento/Ui/view/base/web/js/grid/masonry.js

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,26 @@ define([
4848
* Maximum image height value
4949
* @param int
5050
*/
51-
maxImageHeight: 240
51+
maxImageHeight: 240,
52+
53+
/**
54+
* The value is minimum image width to height ratio when container width is less than the key
55+
*
56+
* @param int
57+
*/
58+
containerWidthToMinRatio: {
59+
640: 3,
60+
1280: 5,
61+
1920: 8
62+
},
63+
64+
/**
65+
* Default minimal image width to height ratio.
66+
* Applied when container width is greater than max width in the containerWidthToMinRatio matrix.
67+
*
68+
* @param int
69+
*/
70+
defaultMinRatio: 10
5271
},
5372

5473
/**
@@ -229,15 +248,17 @@ define([
229248
* Set min ratio for images in layout
230249
*/
231250
setMinRatio: function () {
232-
if (this.containerWidth <= 640) {
233-
this.minRatio = 3;
234-
} else if (this.containerWidth <= 1280) {
235-
this.minRatio = 5;
236-
} else if (this.containerWidth <= 1920) {
237-
this.minRatio = 8;
238-
} else {
239-
this.minRatio = 10;
251+
var minRatio = null;
252+
253+
for (var width in this.containerWidthToMinRatio) {
254+
if (this.containerWidthToMinRatio.hasOwnProperty(width) &&
255+
this.containerWidth <= width
256+
) {
257+
minRatio = this.containerWidthToMinRatio[width]
258+
}
240259
}
260+
261+
this.minRatio = minRatio ? minRatio : this.defaultMinRatio;
241262
},
242263

243264
/**

0 commit comments

Comments
 (0)