11import BaseSortZone from '../../../toolbar/SortZone.mjs' ;
2- import VDomUtil from '../../../../util/VDom.mjs' ;
32
43/**
54 * @class Neo.draggable.grid.header.toolbar.SortZone
@@ -17,6 +16,15 @@ class SortZone extends BaseSortZone {
1716 * @protected
1817 */
1918 ntype : 'grid-header-toolbar-sortzone' ,
19+ /**
20+ * @member {Boolean} adjustProxyRectToParent=true
21+ */
22+ adjustProxyRectToParent : true ,
23+ /**
24+ * @member {String|null} itemMargin=null
25+ * @protected
26+ */
27+ itemMargin : '1px' ,
2028 /**
2129 * @member {Boolean} moveVertical=false
2230 */
@@ -40,84 +48,6 @@ class SortZone extends BaseSortZone {
4048
4149 owner . parent . view . createViewData ( )
4250 }
43-
44- /**
45- * @param {Object } data
46- */
47- onDragStart ( data ) {
48- let me = this ,
49- button = Neo . getComponent ( data . path [ 0 ] . id ) ,
50- { owner} = me ,
51- itemStyles = me . itemStyles = [ ] ,
52- { layout} = owner ,
53- ownerStyle = owner . style || { } ,
54- index , indexMap , itemStyle , ownerRect , rect ;
55-
56- if ( owner . sortable ) {
57- index = owner . indexOf ( button . id ) ;
58- indexMap = { } ;
59-
60- Object . assign ( me , {
61- currentIndex : index ,
62- dragElement : VDomUtil . find ( owner . vdom , button . id ) . vdom ,
63- dragProxyConfig : { ...me . dragProxyConfig , cls : [ ...owner . cls ] } ,
64- indexMap : indexMap ,
65- ownerStyle : { height : ownerStyle . height , width : ownerStyle . width } ,
66- reversedLayoutDirection : layout . direction === 'column-reverse' || layout . direction === 'row-reverse' ,
67- sortDirection : owner . layout . ntype === 'layout-vbox' ? 'vertical' : 'horizontal' ,
68- startIndex : index
69- } ) ;
70-
71- me . dragStart ( data ) ; // we do not want to trigger the super class call here
72-
73- owner . items . forEach ( ( item , index ) => {
74- indexMap [ index ] = index ;
75-
76- itemStyles . push ( {
77- height : item . height ? `${ item . height } px` : item . style ?. height ,
78- width : item . width ? `${ item . width } px` : item . style ?. width
79- } )
80- } ) ;
81-
82- owner . getDomRect ( [ owner . id ] . concat ( owner . items . map ( e => e . id ) ) ) . then ( itemRects => {
83- me . ownerRect = ownerRect = itemRects [ 0 ] ;
84-
85- ownerStyle . height = `${ itemRects [ 0 ] . height } px` ;
86- ownerStyle . width = `${ itemRects [ 0 ] . width } px` ;
87-
88- // the only reason we are adjusting the toolbar style is that there is no min height or width present.
89- // removing items from the layout could trigger a change in size.
90- owner . style = ownerStyle ;
91-
92- itemRects . shift ( ) ;
93- me . itemRects = itemRects ;
94-
95- owner . items . forEach ( ( item , index ) => {
96- itemStyle = item . style || { } ;
97- rect = itemRects [ index ] ;
98-
99- rect . x = rect . x - ownerRect . x - 1 ;
100- rect . y = rect . y - ownerRect . y - 1 ;
101-
102- item . style = Object . assign ( itemStyle , {
103- height : `${ rect . height } px` ,
104- left : `${ rect . left } px` ,
105- margin : '1px' ,
106- position : 'absolute' ,
107- top : `${ rect . top } px` ,
108- width : `${ rect . width } px`
109- } )
110- } ) ;
111-
112- // we need to add a short (1 frame) delay to ensure the item has switched to an absolute position
113- me . timeout ( 5 ) . then ( ( ) => {
114- itemStyle = button . style || { } ;
115- itemStyle . visibility = 'hidden' ;
116- button . style = itemStyle
117- } )
118- } )
119- }
120- }
12151}
12252
12353export default Neo . setupClass ( SortZone ) ;
0 commit comments