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

Function addVertexControllers

src/components/shapes/display_outlines.js:217–289  ·  view source on GitHub ↗
(g)

Source from the content-addressed store, hash-verified

215 }
216
217 function addVertexControllers(g) {
218 vertexDragOptions = [];
219
220 for(var i = 0; i < polygons.length; i++) {
221 var cell = polygons[i];
222
223 var onRect = pointsOnRectangle(cell);
224 var onEllipse = !onRect && pointsOnEllipse(cell);
225
226 vertexDragOptions[i] = [];
227 var len = cell.length;
228 for(var j = 0; j < len; j++) {
229 if(cell[j][0] === 'Z') continue;
230
231 if(onEllipse &&
232 j !== i000 &&
233 j !== i090 &&
234 j !== i180 &&
235 j !== i270
236 ) {
237 continue;
238 }
239
240 var rectSelection = onRect && dragOptions.isActiveSelection;
241 var nextPoint;
242 if(rectSelection) nextPoint = getNextPoint(cell, j);
243
244 var x = cell[j][1];
245 var y = cell[j][2];
246
247 var vertex = g.append(rectSelection ? 'rect' : 'circle')
248 .attr('data-i', i)
249 .attr('data-j', j)
250 .style({
251 fill: Color.background,
252 stroke: Color.defaultLine,
253 'stroke-width': 1,
254 'shape-rendering': 'crispEdges',
255 });
256
257 if(rectSelection) {
258 // convert a vertex controller to an edge controller for rect selections
259 var dx = nextPoint[1] - x;
260 var dy = nextPoint[2] - y;
261
262 var width = dy ? 5 : Math.max(Math.min(25, Math.abs(dx) - 5), 5);
263 var height = dx ? 5 : Math.max(Math.min(25, Math.abs(dy) - 5), 5);
264
265 vertex.classed(dy ? 'cursor-ew-resize' : 'cursor-ns-resize', true)
266 .attr('width', width)
267 .attr('height', height)
268 .attr('x', x - width / 2)
269 .attr('y', y - height / 2)
270 .attr('transform', strTranslate(dx / 2, dy / 2));
271 } else {
272 vertex.classed('cursor-grab', true)
273 .attr('r', 5)
274 .attr('cx', x)

Callers 1

Calls 1

getNextPointFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…