@@ -79,23 +79,37 @@ function createGhost(
7979 node : VNode
8080) : VNode {
8181 const rect = item . getBoundingClientRect ( ) ;
82+ const style = getComputedStyle ( item ) ;
83+ const padding = {
84+ top : parseFloat ( style . paddingTop ) + parseFloat ( style . borderTop ) ,
85+ left : parseFloat ( style . paddingLeft ) + parseFloat ( style . borderLeft ) ,
86+ bottom :
87+ parseFloat ( style . paddingBottom ) + parseFloat ( style . borderBottom ) ,
88+ right : parseFloat ( style . paddingRight ) + parseFloat ( style . borderRight )
89+ } ;
8290 const parentRect = item . parentElement . getBoundingClientRect ( ) ;
83- const offsetX = ev . clientX - rect . left + parentRect . left ;
84- const offsetY = ev . clientY - rect . top + parentRect . top ;
91+ const offsetX =
92+ ev . clientX - rect . left + parentRect . left + parseFloat ( style . marginLeft ) ;
93+ const offsetY =
94+ ev . clientY - rect . top + parentRect . top + parseFloat ( style . marginTop ) ;
95+
96+ const sub = style . boxSizing !== 'border-box' ;
8597
8698 return addDataEntry (
8799 addDataEntry ( node , 'dataset' , {
88100 offsetX,
89101 offsetY,
90- item
102+ item,
103+ ghost : true
91104 } ) ,
92105 'style' ,
93106 {
94107 position : 'absolute' ,
95108 left : ev . clientX - offsetX + 'px' ,
96109 top : ev . clientY - offsetY + 'px' ,
97- width : rect . width + 'px' ,
98- height : rect . height + 'px' ,
110+ width : rect . width - ( sub ? padding . left - padding . right : 0 ) + 'px' ,
111+ height :
112+ rect . height - ( sub ? padding . top - padding . bottom : 0 ) + 'px' ,
99113 'pointer-events' : 'none'
100114 }
101115 ) ;
0 commit comments