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

Function zoomNonClipped

src/plots/geo/zoom.js:111–197  ·  view source on GitHub ↗
(geo, projection)

Source from the content-addressed store, hash-verified

109
110// zoom for non-clipped projections
111function zoomNonClipped(geo, projection) {
112 var zoom = initZoom(geo, projection);
113
114 var INSIDETOLORANCEPXS = 2;
115
116 var mouse0, rotate0, translate0, lastRotate, zoomPoint,
117 mouse1, rotate1, point1, didZoom;
118
119 function position(x) { return projection.invert(x); }
120
121 function outside(x) {
122 var pos = position(x);
123 if(!pos) return true;
124
125 var pt = projection(pos);
126 return (
127 Math.abs(pt[0] - x[0]) > INSIDETOLORANCEPXS ||
128 Math.abs(pt[1] - x[1]) > INSIDETOLORANCEPXS
129 );
130 }
131
132 function handleZoomstart() {
133 d3.select(this).style(zoomstartStyle);
134
135 mouse0 = d3.mouse(this);
136 rotate0 = projection.rotate();
137 translate0 = projection.translate();
138 lastRotate = rotate0;
139 zoomPoint = position(mouse0);
140 }
141
142 function handleZoom() {
143 mouse1 = d3.mouse(this);
144
145 if(outside(mouse0)) {
146 zoom.scale(projection.scale());
147 zoom.translate(projection.translate());
148 return;
149 }
150
151 projection.scale(d3.event.scale);
152 projection.translate([translate0[0], d3.event.translate[1]]);
153
154 if(!zoomPoint) {
155 mouse0 = mouse1;
156 zoomPoint = position(mouse0);
157 } else if(position(mouse1)) {
158 point1 = position(mouse1);
159 rotate1 = [lastRotate[0] + (point1[0] - zoomPoint[0]), rotate0[1], rotate0[2]];
160 projection.rotate(rotate1);
161 lastRotate = rotate1;
162 }
163
164 didZoom = true;
165 geo.render(true);
166
167 var rotate = projection.rotate();
168 var center = projection.invert(geo.midPt);

Callers

nothing calls this directly

Calls 1

initZoomFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…