File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -321,17 +321,31 @@ export default {
321
321
const { Canvas } = editor ;
322
322
const style = target . getStyle ( ) ;
323
323
const position = 'absolute' ;
324
+ const relPos = [ position , 'relative' ] ;
324
325
onStart && onStart ( this . _getDragData ( ) ) ;
325
326
if ( isTran ) return ;
326
327
327
328
if ( style . position !== position ) {
328
329
let { left, top, width, height } = Canvas . offset ( target . getEl ( ) ) ;
330
+ let parent = target . parent ( ) ;
331
+ let parentRel ;
329
332
330
- // Check if to center the target to the pointer position
333
+ // Check for the relative parent
334
+ do {
335
+ const pStyle = parent . getStyle ( ) ;
336
+ parentRel = relPos . indexOf ( pStyle . position ) >= 0 ? parent : null ;
337
+ parent = parent . parent ( ) ;
338
+ } while ( parent && ! parentRel ) ;
339
+
340
+ // Center the target to the pointer position (used in Droppable for Blocks)
331
341
if ( center ) {
332
342
const { x, y } = Canvas . getMouseRelativeCanvas ( event ) ;
333
343
left = x ;
334
344
top = y ;
345
+ } else if ( parentRel ) {
346
+ const offsetP = Canvas . offset ( parentRel . getEl ( ) ) ;
347
+ left = left - offsetP . left ;
348
+ top = top - offsetP . top ;
335
349
}
336
350
337
351
this . setPosition ( {
You can’t perform that action at this time.
0 commit comments