File tree Expand file tree Collapse file tree 3 files changed +24
-7
lines changed
app/code/Magento/Ui/view/base/web Expand file tree Collapse file tree 3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ define([
11
11
defaults : {
12
12
bodyTmpl : 'ui/grid/columns/image' ,
13
13
modules : {
14
+ masonry : '${ $.parentName }' ,
14
15
previewComponent : '${ $.parentName }.preview'
15
16
} ,
16
17
previewRowId : null ,
@@ -35,6 +36,15 @@ define([
35
36
return this ;
36
37
} ,
37
38
39
+ /**
40
+ * Updates styles when image loaded.
41
+ *
42
+ * @param {Object } record
43
+ */
44
+ updateStyles : function ( record ) {
45
+ ! record . lastInRow || this . masonry ( ) . updateStyles ( ) ;
46
+ } ,
47
+
38
48
/**
39
49
* Returns url to given record.
40
50
*
Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ define([
101
101
this . imageMargin = parseInt ( this . imageMargin , 10 ) ;
102
102
this . container = $ ( '[data-id="' + this . containerId + '"]' ) [ 0 ] ;
103
103
104
- this . setLayoutStyles ( ) ;
105
104
this . setEventListener ( ) ;
105
+ this . setLayoutStyles ( ) ;
106
106
107
107
return this ;
108
108
} ,
@@ -112,18 +112,25 @@ define([
112
112
*/
113
113
setEventListener : function ( ) {
114
114
window . addEventListener ( 'resize' , function ( ) {
115
- raf ( function ( ) {
116
- this . containerWidth = window . innerWidth ;
117
- this . setLayoutStyles ( ) ;
118
- } . bind ( this ) , this . refreshFPS ) ;
115
+ this . updateStyles ( ) ;
119
116
} . bind ( this ) ) ;
120
117
} ,
121
118
119
+ /**
120
+ * Updates styles for component.
121
+ */
122
+ updateStyles : function ( ) {
123
+ raf ( function ( ) {
124
+ this . containerWidth = window . innerWidth ;
125
+ this . setLayoutStyles ( ) ;
126
+ } . bind ( this ) , this . refreshFPS ) ;
127
+ } ,
128
+
122
129
/**
123
130
* Set layout styles inside the container
124
131
*/
125
132
setLayoutStyles : function ( ) {
126
- var containerWidth = parseInt ( this . container . clientWidth , 10 ) - 15 ,
133
+ var containerWidth = parseInt ( this . container . clientWidth , 10 ) ,
127
134
rowImages = [ ] ,
128
135
ratio = 0 ,
129
136
rowHeight = 0 ,
Original file line number Diff line number Diff line change 5
5
*/
6
6
-->
7
7
< div class ="masonry-image-block " ko-style ="$col.getStyles($row()) " css ="{'active': $col.getIsActive($row())} " attr ="'data-id': $col.getId($row()) ">
8
- < img attr ="src: $col.getUrl($row()) " css ="$col.getClasses($row()) " click ="function(){ expandPreview($row()) } " data-role ="thumbnail "/>
8
+ < img data-bind =" event: { load: updateStyles($row()) } " attr ="src: $col.getUrl($row()) " css ="$col.getClasses($row()) " click ="function(){ expandPreview($row()) } " data-role ="thumbnail "/>
9
9
</ div >
You can’t perform that action at this time.
0 commit comments