@@ -306,14 +306,22 @@ export function startDragOnPointerDown(
306306
307307 const domRect = dom . getBoundingClientRect ( ) ;
308308
309- const transform = new DOMMatrixReadOnly ( getComputedStyle ( dom ) . transform ) ;
309+ const domStyle = getComputedStyle ( dom ) ;
310+ const transform = new DOMMatrixReadOnly ( domStyle . transform ) ;
310311 const originX = transform . m41 ;
311312 const originY = transform . m42 ;
312313
313314 const startX = clientX ;
314315 const startY = clientY ;
315316
316- const translateCalc = new TranslateCalculator ( originX , originY , startX , startY , domRect ) ;
317+ const translateCalc = new TranslateCalculator (
318+ originX ,
319+ originY ,
320+ startX ,
321+ startY ,
322+ domRect ,
323+ parseInt ( domStyle . marginTop , 10 ) ,
324+ ) ;
317325
318326 let clone : HTMLElement | null = null ;
319327 let initialStyles : InitialStyles | null = null ;
@@ -455,11 +463,31 @@ function startDrag(dom: HTMLElement, translateCalc: TranslateCalculator) {
455463 const bodyRect = document . body . getBoundingClientRect ( ) ;
456464
457465 const clone = dom . cloneNode ( true ) as HTMLElement ;
466+
467+ let cloneQueue : Element [ ] = [ clone ] ;
468+ let domQueue : Element [ ] = [ dom ] ;
469+
470+ while ( cloneQueue . length && domQueue . length ) {
471+ const domElement = domQueue . pop ( ) ;
472+ const cloneElement = cloneQueue . pop ( ) ;
473+
474+ if ( ! ( domElement instanceof HTMLElement && cloneElement instanceof HTMLElement ) ) {
475+ continue ;
476+ }
477+
478+ const domStyles = getComputedStyle ( domElement ) ;
479+ for ( let i = 0 ; i < domStyles . length ; i ++ ) {
480+ const property = domStyles . item ( i ) ;
481+ cloneElement . style . setProperty ( property , domStyles . getPropertyValue ( property ) ) ;
482+ }
483+
484+ cloneQueue . push ( ...cloneElement . children ) ;
485+ domQueue . push ( ...domElement . children ) ;
486+ }
487+
458488 clone . style . position = "absolute" ;
459489 clone . style . top = `${ domRect . top - bodyRect . top } px` ;
460490 clone . style . left = `${ domRect . left - bodyRect . left } px` ;
461- clone . style . width = `${ domRect . width } px` ;
462- clone . style . height = `${ domRect . height } px` ;
463491 document . body . appendChild ( clone ) ;
464492
465493 dom . dataset [ "shuffleActive" ] = "true" ;
0 commit comments