@@ -1152,7 +1152,7 @@ d3 = function() {
11521152 return d3 . rebind ( drag , event , "on" ) ;
11531153 } ;
11541154 d3 . behavior . zoom = function ( ) {
1155- var translate = [ 0 , 0 ] , translate0 , scale = 1 , scaleExtent = d3_behavior_zoomInfinity , mousedown = "mousedown.zoom" , mousemove = "mousemove.zoom" , mouseup = "mouseup.zoom" , touchstart = "touchstart.zoom" , touchmove = "touchmove.zoom" , touchend = "touchend.zoom" , event = d3_eventDispatch ( zoom , "zoom" ) , x0 , x1 , y0 , y1 ;
1155+ var translate = [ 0 , 0 ] , translate0 , scale = 1 , scaleExtent = d3_behavior_zoomInfinity , mousedown = "mousedown.zoom" , mousemove = "mousemove.zoom" , mouseup = "mouseup.zoom" , touchstart = "touchstart.zoom" , touchmove = "touchmove.zoom" , touchend = "touchend.zoom" , touchtime , event = d3_eventDispatch ( zoom , "zoom" ) , x0 , x1 , y0 , y1 ;
11561156 function zoom ( ) {
11571157 this . on ( mousedown , mousedowned ) . on ( d3_behavior_zoomWheel + ".zoom" , mousewheeled ) . on ( mousemove , mousewheelreset ) . on ( "dblclick.zoom" , dblclicked ) . on ( touchstart , touchstarted ) ;
11581158 }
@@ -1232,15 +1232,19 @@ d3 = function() {
12321232 }
12331233 }
12341234 function touchstarted ( ) {
1235- var target = this , event_ = event . of ( target , arguments ) , locations , distance0 = 0 , scale0 , w = d3 . select ( d3_window ) . on ( touchmove , moved ) . on ( touchend , ended ) , t = d3 . select ( target ) . on ( mousedown , null ) . on ( touchstart , started ) , dragRestore = d3_event_dragSuppress ( ) , touchtime ;
1235+ var target = this , event_ = event . of ( target , arguments ) , locations0 , distance0 = 0 , scale0 , w = d3 . select ( d3_window ) . on ( touchmove , moved ) . on ( touchend , ended ) , t = d3 . select ( target ) . on ( mousedown , null ) . on ( touchstart , started ) , dragRestore = d3_event_dragSuppress ( ) ;
12361236 started ( ) ;
1237- function started ( ) {
1238- var now = Date . now ( ) , touches = d3 . touches ( target ) ;
1237+ function relocate ( ) {
1238+ var touches = d3 . touches ( target ) ;
12391239 scale0 = scale ;
1240- locations = { } ;
1240+ locations0 = { } ;
12411241 touches . forEach ( function ( t ) {
1242- locations [ t . identifier ] = location ( t ) ;
1242+ locations0 [ t . identifier ] = location ( t ) ;
12431243 } ) ;
1244+ return touches ;
1245+ }
1246+ function started ( ) {
1247+ var now = Date . now ( ) , touches = relocate ( ) ;
12441248 if ( touches . length === 1 ) {
12451249 if ( now - touchtime < 500 ) {
12461250 var p = touches [ 0 ] , l = location ( touches [ 0 ] ) ;
@@ -1256,9 +1260,9 @@ d3 = function() {
12561260 }
12571261 }
12581262 function moved ( ) {
1259- var touches = d3 . touches ( target ) , p0 = touches [ 0 ] , l0 = locations [ p0 . identifier ] ;
1263+ var touches = d3 . touches ( target ) , p0 = touches [ 0 ] , l0 = locations0 [ p0 . identifier ] ;
12601264 if ( p1 = touches [ 1 ] ) {
1261- var p1 , l1 = locations [ p1 . identifier ] , scale1 = d3 . event . scale ;
1265+ var p1 , l1 = locations0 [ p1 . identifier ] , scale1 = d3 . event . scale ;
12621266 if ( scale1 == null ) {
12631267 var distance1 = ( distance1 = p1 [ 0 ] - p0 [ 0 ] ) * distance1 + ( distance1 = p1 [ 1 ] - p0 [ 1 ] ) * distance1 ;
12641268 scale1 = distance0 && Math . sqrt ( distance1 / distance0 ) ;
@@ -1273,8 +1277,7 @@ d3 = function() {
12731277 }
12741278 function ended ( ) {
12751279 if ( d3 . event . touches . length ) {
1276- touchtime = null ;
1277- started ( ) ;
1280+ relocate ( ) ;
12781281 } else {
12791282 w . on ( touchmove , null ) . on ( touchend , null ) ;
12801283 t . on ( mousedown , mousedowned ) . on ( touchstart , touchstarted ) ;
0 commit comments