@@ -133,16 +133,21 @@ function zoomNonClipped(geo, projection) {
133
133
function handleZoomstart ( ) {
134
134
d3 . select ( this ) . style ( zoomstartStyle ) ;
135
135
136
- mouse0 = d3 . mouse ( this ) ;
136
+ const { bottom, left, right, top } = this . getBoundingClientRect ( )
137
+ mouse0 = d3 . event . sourceEvent
138
+ ? d3 . mouse ( this )
139
+ : [ ( left + right ) / 2 , ( bottom + top ) / 2 ] ;
137
140
rotate0 = projection . rotate ( ) ;
138
141
translate0 = projection . translate ( ) ;
139
142
lastRotate = rotate0 ;
140
143
zoomPoint = position ( mouse0 ) ;
141
144
}
142
145
143
146
function handleZoom ( ) {
144
- mouse1 = d3 . mouse ( this ) ;
145
-
147
+ const { bottom, left, right, top } = this . getBoundingClientRect ( )
148
+ mouse1 = d3 . event . sourceEvent
149
+ ? d3 . mouse ( this )
150
+ : [ ( left + right ) / 2 , ( bottom + top ) / 2 ] ;
146
151
if ( outside ( mouse0 ) ) {
147
152
zoom . scale ( projection . scale ( ) ) ;
148
153
zoom . translate ( projection . translate ( ) ) ;
@@ -211,7 +216,10 @@ function zoomClipped(geo, projection) {
211
216
zoom . on ( 'zoomstart' , function ( ) {
212
217
d3 . select ( this ) . style ( zoomstartStyle ) ;
213
218
214
- var mouse0 = d3 . mouse ( this ) ;
219
+ const { bottom, left, right, top } = this . getBoundingClientRect ( )
220
+ let mouse0 = d3 . event . sourceEvent
221
+ ? d3 . mouse ( this )
222
+ : [ ( left + right ) / 2 , ( bottom + top ) / 2 ] ;
215
223
var rotate0 = projection . rotate ( ) ;
216
224
var lastRotate = rotate0 ;
217
225
var translate0 = projection . translate ( ) ;
@@ -220,7 +228,10 @@ function zoomClipped(geo, projection) {
220
228
zoomPoint = position ( projection , mouse0 ) ;
221
229
222
230
zoomOn . call ( zoom , 'zoom' , function ( ) {
223
- var mouse1 = d3 . mouse ( this ) ;
231
+ const { bottom, left, right, top } = this . getBoundingClientRect ( )
232
+ let mouse1 = d3 . event . sourceEvent
233
+ ? d3 . mouse ( this )
234
+ : [ ( left + right ) / 2 , ( bottom + top ) / 2 ] ;
224
235
225
236
projection . scale ( view . k = d3 . event . scale ) ;
226
237
0 commit comments