@@ -133,16 +133,21 @@ function zoomNonClipped(geo, projection) {
133133 function handleZoomstart ( ) {
134134 d3 . select ( this ) . style ( zoomstartStyle ) ;
135135
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 ] ;
137140 rotate0 = projection . rotate ( ) ;
138141 translate0 = projection . translate ( ) ;
139142 lastRotate = rotate0 ;
140143 zoomPoint = position ( mouse0 ) ;
141144 }
142145
143146 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 ] ;
146151 if ( outside ( mouse0 ) ) {
147152 zoom . scale ( projection . scale ( ) ) ;
148153 zoom . translate ( projection . translate ( ) ) ;
@@ -211,7 +216,10 @@ function zoomClipped(geo, projection) {
211216 zoom . on ( 'zoomstart' , function ( ) {
212217 d3 . select ( this ) . style ( zoomstartStyle ) ;
213218
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 ] ;
215223 var rotate0 = projection . rotate ( ) ;
216224 var lastRotate = rotate0 ;
217225 var translate0 = projection . translate ( ) ;
@@ -220,7 +228,10 @@ function zoomClipped(geo, projection) {
220228 zoomPoint = position ( projection , mouse0 ) ;
221229
222230 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 ] ;
224235
225236 projection . scale ( view . k = d3 . event . scale ) ;
226237
0 commit comments