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

Function plotDrag

src/plots/cartesian/dragbox.js:554–690  ·  view source on GitHub ↗
(dx, dy)

Source from the content-addressed store, hash-verified

552
553 // plotDrag: move the plot in response to a drag
554 function plotDrag(dx, dy) {
555 dx = dx * scaleX;
556 dy = dy * scaleY;
557 // If a transition is in progress, then disable any behavior:
558 if(gd._transitioningWithDuration) {
559 return;
560 }
561
562 // prevent axis drawing from monkeying with margins until we're done
563 gd._fullLayout._replotting = true;
564
565 if(xActive === 'ew' || yActive === 'ns') {
566 var spDx = xActive ? -dx : 0;
567 var spDy = yActive ? -dy : 0;
568
569 if(matches.isSubplotConstrained) {
570 if(xActive && yActive) {
571 var frac = (dx / pw - dy / ph) / 2;
572 dx = frac * pw;
573 dy = -frac * ph;
574 spDx = -dx;
575 spDy = -dy;
576 }
577 if(yActive) {
578 spDx = -spDy * pw / ph;
579 } else {
580 spDy = -spDx * ph / pw;
581 }
582 }
583 if(xActive) {
584 dragAxList(xaxes, dx);
585 updateMatchedAxRange('x');
586 }
587 if(yActive) {
588 dragAxList(yaxes, dy);
589 updateMatchedAxRange('y');
590 }
591 updateSubplots([spDx, spDy, pw, ph]);
592 ticksAndAnnotations();
593 gd.emit('plotly_relayouting', updates);
594 return;
595 }
596
597 // dz: set a new value for one end (0 or 1) of an axis array axArray,
598 // and return a pixel shift for that end for the viewbox
599 // based on pixel drag distance d
600 // TODO: this makes (generally non-fatal) errors when you get
601 // near floating point limits
602 function dz(axArray, end, d) {
603 var otherEnd = 1 - end;
604 var movedAx;
605 var newLinearizedEnd;
606 for(var i = 0; i < axArray.length; i++) {
607 var axi = axArray[i];
608 if(axi.fixedrange) continue;
609 movedAx = axi;
610 newLinearizedEnd = axi._rl[otherEnd] +
611 (axi._rl[end] - axi._rl[otherEnd]) / dZoom(d / axi._length);

Callers

nothing calls this directly

Calls 5

dragAxListFunction · 0.85
updateMatchedAxRangeFunction · 0.85
updateSubplotsFunction · 0.85
ticksAndAnnotationsFunction · 0.85
dzFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…