@@ -51,7 +51,9 @@ export default (Builder, CanMoveFn = null) => {
5151 startDragging . plY = plY ;
5252 startDragging . itemInfo = clone ( dragging . itemInfo ) ;
5353 startDragging . y = plhEl . offsetTop ;
54+ startDragging . x = plhEl . offsetLeft ;
5455 startDragging . clientY += ( plY - oldPlY ) ;
56+ startDragging . clientX += ( plX - oldPlX ) ;
5557
5658 this . _onDrag ( this . mousePos , false ) ;
5759 }
@@ -264,8 +266,8 @@ export default (Builder, CanMoveFn = null) => {
264266 var isGroup = hovCNodeEl . classList . contains ( 'group-container' ) ;
265267 var hovNodeId = hovCNodeEl . getAttribute ( 'data-id' ) ;
266268 var hovEl = hovCNodeEl ;
267- var onlyAppend = false ;
268- var onlyPrepend = false ;
269+ var doAppend = false ;
270+ var doPrepend = false ;
269271 if ( hovEl ) {
270272 var hovRect = hovEl . getBoundingClientRect ( ) ;
271273 var hovHeight = hovRect . bottom - hovRect . top ;
@@ -292,25 +294,26 @@ export default (Builder, CanMoveFn = null) => {
292294 trgII = hovII ;
293295 trgRect = hovRect2 ;
294296 trgEl = hovEl2 ;
295- onlyPrepend = true ;
297+ doPrepend = true ;
296298 }
297299 } else if ( dragDirs . vrt < 0 ) { //up
298300 if ( hovII . lev >= itemInfo . lev ) {
299301 //take whole group
300- var isClimbToHover = ( ( hovRect . bottom - dragRect . top ) >= 5 ) ; //todo: 5 is magic for now, configure it!
302+ //todo: 5 is magic for now (bottom margin), configure it!
303+ var isClimbToHover = ( ( hovRect . bottom - dragRect . top ) >= 2 ) ;
301304 if ( isClimbToHover && hovII . top < dragInfo . itemInfo . top ) {
302305 trgII = hovII ;
303306 trgRect = hovRect ;
304307 trgEl = hovEl ;
305- onlyAppend = true ;
308+ doAppend = true ;
306309 }
307310 }
308311 }
309- if ( ! onlyPrepend && ! onlyAppend ) {
312+ if ( ! doPrepend && ! doAppend ) {
310313 //take whole group and check if we can move before/after group
311314 var isOverHover = ( dragDirs . vrt < 0 //up
312- ? ( ( hovRect . bottom - dragRect . top ) > ( hovHeight - 2 ) )
313- : ( ( dragRect . bottom - hovRect . top ) > ( hovHeight - 2 ) ) ) ;
315+ ? ( ( hovRect . bottom - dragRect . top ) > ( hovHeight - 5 ) )
316+ : ( ( dragRect . bottom - hovRect . top ) > ( hovHeight - 5 ) ) ) ;
314317 if ( isOverHover ) {
315318 trgII = hovII ;
316319 trgRect = hovRect ;
@@ -340,20 +343,17 @@ export default (Builder, CanMoveFn = null) => {
340343 if ( isSamePos ) {
341344 //do nothing
342345 } else {
343- //find out where we can move..
344346 if ( isGroup ) {
345- if ( onlyAppend ) {
347+ if ( doAppend ) {
346348 availMoves . push ( [ constants . PLACEMENT_APPEND , trgII , trgII . lev + 1 ] ) ;
347- }
348- if ( onlyPrepend ) {
349+ } else if ( doPrepend ) {
349350 availMoves . push ( [ constants . PLACEMENT_PREPEND , trgII , trgII . lev + 1 ] ) ;
350351 }
351352 }
352- if ( ! onlyAppend && ! onlyPrepend ) {
353+ if ( ! doAppend && ! doPrepend ) {
353354 if ( dragDirs . vrt < 0 ) {
354355 availMoves . push ( [ constants . PLACEMENT_BEFORE , trgII , trgII . lev ] ) ;
355- }
356- if ( dragDirs . vrt > 0 && ( trgII . leaf || trgII . collapsed || ! trgII . leaf && trgII . top < dragInfo . itemInfo . top ) ) {
356+ } else if ( dragDirs . vrt > 0 ) {
357357 availMoves . push ( [ constants . PLACEMENT_AFTER , trgII , trgII . lev ] ) ;
358358 }
359359 }
0 commit comments