MCPcopy Index your code
hub / github.com/plotly/plotly.js / zoomMove

Function zoomMove

src/plots/cartesian/dragbox.js:348–432  ·  view source on GitHub ↗
(dx0, dy0)

Source from the content-addressed store, hash-verified

346 }
347
348 function zoomMove(dx0, dy0) {
349 if(gd._transitioningWithDuration) {
350 return false;
351 }
352
353 var x1 = Math.max(0, Math.min(pw, scaleX * dx0 + x0));
354 var y1 = Math.max(0, Math.min(ph, scaleY * dy0 + y0));
355 var dx = Math.abs(x1 - x0);
356 var dy = Math.abs(y1 - y0);
357
358 box.l = Math.min(x0, x1);
359 box.r = Math.max(x0, x1);
360 box.t = Math.min(y0, y1);
361 box.b = Math.max(y0, y1);
362
363 function noZoom() {
364 zoomMode = '';
365 box.r = box.l;
366 box.t = box.b;
367 corners.attr('d', 'M0,0Z');
368 }
369
370 if(links.isSubplotConstrained) {
371 if(dx > MINZOOM || dy > MINZOOM) {
372 zoomMode = 'xy';
373 if(dx / pw > dy / ph) {
374 dy = dx * ph / pw;
375 if(y0 > y1) box.t = y0 - dy;
376 else box.b = y0 + dy;
377 } else {
378 dx = dy * pw / ph;
379 if(x0 > x1) box.l = x0 - dx;
380 else box.r = x0 + dx;
381 }
382 corners.attr('d', xyCorners(box));
383 } else {
384 noZoom();
385 }
386 } else if(matches.isSubplotConstrained) {
387 if(dx > MINZOOM || dy > MINZOOM) {
388 zoomMode = 'xy';
389
390 var r0 = Math.min(box.l / pw, (ph - box.b) / ph);
391 var r1 = Math.max(box.r / pw, (ph - box.t) / ph);
392
393 box.l = r0 * pw;
394 box.r = r1 * pw;
395 box.b = (1 - r0) * ph;
396 box.t = (1 - r1) * ph;
397 corners.attr('d', xyCorners(box));
398 } else {
399 noZoom();
400 }
401 } else if(!yActive || dy < Math.min(Math.max(dx * 0.6, MINDRAG), MINZOOM)) {
402 // look for small drags in one direction or the other,
403 // and only drag the other axis
404
405 if(dx < MINDRAG || !xActive) {

Callers

nothing calls this directly

Calls 6

xyCornersFunction · 0.85
noZoomFunction · 0.85
xCornersFunction · 0.85
yCornersFunction · 0.85
updateZoomboxFunction · 0.85
computeZoomUpdatesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…