Skip to content

Commit d46e645

Browse files
ENGCOM-6244: Added masonry grid and columns components #25464
- Merge Pull Request #25464 from sivaschenko/magento2:masonry-overlay - Merged commits: 1. 81d2758 2. c0119d9 3. c657fb2 4. 5aebbc0 5. 02dfa0d 6. f7784b5 7. c3f8623 8. 0e5eaaf 9. 4787165 10. 2c0f863 11. ea18bd7 12. 6023ac7
2 parents 7d3938b + 6023ac7 commit d46e645

File tree

1 file changed

+14
-24
lines changed
  • app/code/Magento/Ui/view/base/web/js/grid

1 file changed

+14
-24
lines changed

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

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
*/
55
define([
66
'Magento_Ui/js/grid/listing',
7+
'Magento_Ui/js/lib/view/utils/raf',
78
'jquery',
89
'ko',
910
'underscore'
10-
], function (Listing, $, ko, _) {
11+
], function (Listing, raf, $, ko, _) {
1112
'use strict';
1213

1314
return Listing.extend({
@@ -18,7 +19,7 @@ define([
1819
errorMessage: '${ $.provider }:data.errorMessage'
1920
},
2021
listens: {
21-
'rows': 'initComponent'
22+
rows: 'initComponent'
2223
},
2324

2425
/**
@@ -66,7 +67,12 @@ define([
6667
* Applied when container width is greater than max width in the containerWidthToMinRatio matrix.
6768
* @param int
6869
*/
69-
defaultMinRatio: 10
70+
defaultMinRatio: 10,
71+
72+
/**
73+
* Layout update FPS during window resizing
74+
*/
75+
refreshFPS: 60
7076
},
7177

7278
/**
@@ -105,29 +111,12 @@ define([
105111
* Set event listener to track resize event
106112
*/
107113
setEventListener: function () {
108-
var running = false,
109-
handler = function () {
114+
window.addEventListener('resize', function () {
115+
raf(function () {
110116
this.containerWidth = window.innerWidth;
111117
this.setLayoutStyles();
112-
}.bind(this);
113-
114-
window.addEventListener('resize', function () {
115-
if (!running) {
116-
running = true;
117-
118-
if (window.requestAnimationFrame) {
119-
window.requestAnimationFrame(function () {
120-
handler();
121-
running = false;
122-
});
123-
} else {
124-
setTimeout(function () {
125-
handler();
126-
running = false;
127-
}, 66);
128-
}
129-
}
130-
});
118+
}.bind(this), this.refreshFPS);
119+
}.bind(this));
131120
},
132121

133122
/**
@@ -249,6 +238,7 @@ define([
249238
setMinRatio: function () {
250239
var minRatio = _.find(
251240
this.containerWidthToMinRatio,
241+
252242
/**
253243
* Find the minimal ratio for container width in the matrix
254244
*

0 commit comments

Comments
 (0)