MCPcopy Create free account
hub / github.com/plotly/plotly.js / zoomMove

Function zoomMove

src/plots/ternary/ternary.js:627–671  ·  view source on GitHub ↗
(dx0, dy0)

Source from the content-addressed store, hash-verified

625 function getCFrac(x, y) { return ((x - (_this.h - y) / Math.sqrt(3)) / _this.w); }
626
627 function zoomMove(dx0, dy0) {
628 var x1 = x0 + dx0 * scaleX;
629 var y1 = y0 + dy0 * scaleY;
630 var afrac = Math.max(0, Math.min(1, getAFrac(x0, y0), getAFrac(x1, y1)));
631 var bfrac = Math.max(0, Math.min(1, getBFrac(x0, y0), getBFrac(x1, y1)));
632 var cfrac = Math.max(0, Math.min(1, getCFrac(x0, y0), getCFrac(x1, y1)));
633 var xLeft = ((afrac / 2) + cfrac) * _this.w;
634 var xRight = (1 - (afrac / 2) - bfrac) * _this.w;
635 var xCenter = (xLeft + xRight) / 2;
636 var xSpan = xRight - xLeft;
637 var yBottom = (1 - afrac) * _this.h;
638 var yTop = yBottom - xSpan / whRatio;
639
640 if(xSpan < constants.MINZOOM) {
641 mins = mins0;
642 zb.attr('d', path0);
643 corners.attr('d', 'M0,0Z');
644 } else {
645 mins = {
646 a: mins0.a + afrac * span0,
647 b: mins0.b + bfrac * span0,
648 c: mins0.c + cfrac * span0
649 };
650 zb.attr('d', path0 + 'M' + xLeft + ',' + yBottom +
651 'H' + xRight + 'L' + xCenter + ',' + yTop +
652 'L' + xLeft + ',' + yBottom + 'Z');
653 corners.attr('d', 'M' + x0 + ',' + y0 + STARTMARKER +
654 'M' + xLeft + ',' + yBottom + BLPATH +
655 'M' + xRight + ',' + yBottom + BRPATH +
656 'M' + xCenter + ',' + yTop + TOPPATH);
657 }
658
659 if(!dimmed) {
660 zb.transition()
661 .style('fill', lum > 0.2 ? 'rgba(0,0,0,0.4)' :
662 'rgba(255,255,255,0.3)')
663 .duration(200);
664 corners.transition()
665 .style('opacity', 1)
666 .duration(200);
667 dimmed = true;
668 }
669
670 gd.emit('plotly_relayouting', makeUpdate(mins));
671 }
672
673 function zoomDone() {
674 removeZoombox(gd);

Callers

nothing calls this directly

Calls 4

getAFracFunction · 0.85
getBFracFunction · 0.85
getCFracFunction · 0.85
makeUpdateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…