@@ -24,6 +24,20 @@ export class AppComponent implements OnInit {
2424 xl : 'yXl'
2525 } ;
2626
27+ static W_PROPERTY_MAP : any = {
28+ sm : 'wSm' ,
29+ md : 'wMd' ,
30+ lg : 'wLg' ,
31+ xl : 'wXl'
32+ } ;
33+
34+ static H_PROPERTY_MAP : any = {
35+ sm : 'hSm' ,
36+ md : 'hMd' ,
37+ lg : 'hLg' ,
38+ xl : 'hXl'
39+ } ;
40+
2741 @ViewChild ( GridsterComponent ) gridster : GridsterComponent ;
2842 itemOptions = {
2943 maxWidth : 3 ,
@@ -51,6 +65,7 @@ export class AppComponent implements OnInit {
5165 useCSSTransforms : true ,
5266 responsiveView : true , // turn on adopting items sizes on window resize and enable responsiveOptions
5367 responsiveDebounce : 500 , // window resize debounce time
68+ responsiveSizes : true ,
5469 // List of different gridster configurations for different breakpoints.
5570 // Each breakpoint is defined by name stored in "breakpoint" property. There is fixed set of breakpoints
5671 // available to use with default minWidth assign to each.
@@ -92,30 +107,53 @@ export class AppComponent implements OnInit {
92107 {
93108 x : 0 , y : 0 ,
94109 w : 1 , h : 2 ,
110+ wSm : 1 , hSm : 1 ,
111+ wMd : 1 , hMd : 2 ,
112+ wLg : 1 , hLg : 1 ,
113+ wXl : 2 , hXl : 2 ,
95114 dragAndDrop : true ,
96115 resizable : true ,
97116 title : 'Basic form inputs 1'
98117 } ,
99118 {
100- x : 1 , y : 0 , w : 3 , h : 1 ,
119+ x : 1 , y : 0 ,
120+ w : 1 , h : 2 ,
121+ wSm : 2 , hSm : 1 ,
122+ wMd : 2 , hMd : 1 ,
123+ wLg : 3 , hLg : 1 ,
124+ wXl : 3 , hXl : 1 ,
101125 dragAndDrop : true ,
102126 resizable : true ,
103127 title : 'Basic form inputs 2'
104128 } ,
105129 {
106- x : 1 , y : 1 , w : 2 , h : 1 ,
130+ x : 1 , y : 1 ,
131+ w : 2 , h : 1 ,
132+ wSm : 1 , hSm : 2 ,
133+ wMd : 1 , hMd : 2 ,
134+ wLg : 2 , hLg : 1 ,
135+ wXl : 3 , hXl : 1 ,
107136 dragAndDrop : true ,
108137 resizable : true ,
109138 title : 'Basic form inputs 3'
110139 } ,
111140 {
112- x : 3 , y : 1 , w : 1 , h : 2 ,
141+ x : 3 , y : 1 ,
142+ w : 1 , h : 2 ,
143+ wSm : 1 , hSm : 2 ,
144+ wMd : 1 , hMd : 2 ,
145+ wLg : 3 , hLg : 1 ,
146+ wXl : 3 , hXl : 1 ,
113147 dragAndDrop : true ,
114148 resizable : true ,
115149 title : 'Basic form inputs 4'
116150 } ,
117151 {
118152 w : 1 , h : 2 ,
153+ wSm : 1 , hSm : 2 ,
154+ wMd : 1 , hMd : 2 ,
155+ wLg : 3 , hLg : 1 ,
156+ wXl : 3 , hXl : 1 ,
119157 dragAndDrop : true ,
120158 resizable : true ,
121159 title : 'Basic form inputs x'
@@ -184,14 +222,21 @@ export class AppComponent implements OnInit {
184222 const item = event . item ;
185223 const breakpoint = gridster . options . breakpoint ;
186224 const widget = {
187- w : item . w , h : item . h ,
188225 dragAndDrop : true ,
189226 resizable : true ,
190227 title : 'New widget'
191228 } ;
192229
193- widget [ AppComponent . X_PROPERTY_MAP [ breakpoint ] ] = item . x ;
194- widget [ AppComponent . Y_PROPERTY_MAP [ breakpoint ] ] = item . y ;
230+ widget [ AppComponent . W_PROPERTY_MAP [ breakpoint ] || 'w' ] = item . w ;
231+ widget [ AppComponent . H_PROPERTY_MAP [ breakpoint ] || 'h' ] = item . h ;
232+ widget [ AppComponent . X_PROPERTY_MAP [ breakpoint ] || 'x' ] = item . x ;
233+ widget [ AppComponent . Y_PROPERTY_MAP [ breakpoint ] || 'y' ] = item . y ;
234+
235+ for ( const rwdProp of [ 'wSm' , 'hSm' , 'wMd' , 'hMd' , 'wLg' , 'hLg' , 'wXl' , 'hXl' ] ) {
236+ if ( event . item . itemPrototype . hasOwnProperty ( rwdProp ) ) {
237+ widget [ rwdProp ] = event . item . itemPrototype [ rwdProp ] ;
238+ }
239+ }
195240
196241 this . widgets . push ( widget ) ;
197242
0 commit comments