4
4
*/
5
5
define ( [
6
6
'Magento_Ui/js/grid/listing' ,
7
+ 'Magento_Ui/js/lib/view/utils/raf' ,
7
8
'jquery' ,
8
9
'ko' ,
9
10
'underscore'
10
- ] , function ( Listing , $ , ko , _ ) {
11
+ ] , function ( Listing , raf , $ , ko , _ ) {
11
12
'use strict' ;
12
13
13
14
return Listing . extend ( {
@@ -18,7 +19,7 @@ define([
18
19
errorMessage : '${ $.provider }:data.errorMessage'
19
20
} ,
20
21
listens : {
21
- ' rows' : 'initComponent'
22
+ rows : 'initComponent'
22
23
} ,
23
24
24
25
/**
@@ -66,7 +67,12 @@ define([
66
67
* Applied when container width is greater than max width in the containerWidthToMinRatio matrix.
67
68
* @param int
68
69
*/
69
- defaultMinRatio : 10
70
+ defaultMinRatio : 10 ,
71
+
72
+ /**
73
+ * Layout update FPS during window resizing
74
+ */
75
+ refreshFPS : 60
70
76
} ,
71
77
72
78
/**
@@ -105,29 +111,12 @@ define([
105
111
* Set event listener to track resize event
106
112
*/
107
113
setEventListener : function ( ) {
108
- var running = false ,
109
- handler = function ( ) {
114
+ window . addEventListener ( 'resize' , function ( ) {
115
+ raf ( function ( ) {
110
116
this . containerWidth = window . innerWidth ;
111
117
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 ) ) ;
131
120
} ,
132
121
133
122
/**
@@ -249,6 +238,7 @@ define([
249
238
setMinRatio : function ( ) {
250
239
var minRatio = _ . find (
251
240
this . containerWidthToMinRatio ,
241
+
252
242
/**
253
243
* Find the minimal ratio for container width in the matrix
254
244
*
0 commit comments