@@ -79,23 +79,37 @@ function createGhost(
79
79
node : VNode
80
80
) : VNode {
81
81
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
+ } ;
82
90
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' ;
85
97
86
98
return addDataEntry (
87
99
addDataEntry ( node , 'dataset' , {
88
100
offsetX,
89
101
offsetY,
90
- item
102
+ item,
103
+ ghost : true
91
104
} ) ,
92
105
'style' ,
93
106
{
94
107
position : 'absolute' ,
95
108
left : ev . clientX - offsetX + 'px' ,
96
109
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' ,
99
113
'pointer-events' : 'none'
100
114
}
101
115
) ;
0 commit comments