@@ -31,7 +31,7 @@ export function applyDefaults(options : SortableOptions, root : VNode) : Sortabl
3131 * @param {key } can be used to specify a inital key
3232 * @return {VNode } a new VNode with the keys
3333 */
34- export function addKeys ( node : VNode , key : string = 'key' ) : VNode
34+ export function addKeys ( node : VNode , key : string = Math . random ( ) . toString ( ) ) : VNode
3535{
3636 if ( ! node . children ) {
3737 return { ...node , key } ;
@@ -102,11 +102,22 @@ export function replaceNode(root : VNode, selector : string, replacement : VNode
102102export function getGhostStyle ( event : MouseEvent , mouseOffset : MouseOffset , item : Element ) : string
103103{
104104 const itemRect : ClientRect = item . getBoundingClientRect ( ) ;
105- const body : Element = findParent ( item , 'body' ) ;
106105 return 'z-index: 5; margin: 0; pointer-events: none; position: absolute; width: '
107106 + itemRect . width + 'px; ' + 'height: ' + itemRect . height + 'px; top: '
108- + ( event . clientY + mouseOffset . y + body . scrollTop ) + 'px; left: '
109- + ( event . clientX + mouseOffset . x + body . scrollLeft ) + 'px;' ;
107+ + ( event . clientY + mouseOffset . y + document . body . scrollTop ) + 'px; left: '
108+ + ( event . clientX + mouseOffset . x + document . body . scrollLeft ) + 'px;' ;
109+ }
110+
111+ /**
112+ * Returns the updated style for this ghost element
113+ */
114+ export function updateGhostStyle ( event : MouseEvent , mouseOffset : MouseOffset , ghost : Element ) : string
115+ {
116+ const prevStyle : string = ghost . getAttribute ( 'style' ) ;
117+
118+ return prevStyle . substring ( 0 , prevStyle . indexOf ( ' top:' ) ) + ' top: '
119+ + ( event . clientY + mouseOffset . y + document . body . scrollTop ) + 'px; left: '
120+ + ( event . clientX + mouseOffset . x + document . body . scrollLeft ) + 'px;' ;
110121}
111122
112123/**
0 commit comments