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

Function startDrag

src/components/shapes/draw.js:424–476  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

422 }
423
424 function startDrag(evt) {
425 if (shouldSkipEdits(gd)) return;
426
427 // setup update strings and initial values
428 if (xPixelSized) {
429 xAnchor = x2p(shapeOptions.xanchor);
430 }
431 if (yPixelSized) {
432 yAnchor = y2p(shapeOptions.yanchor);
433 }
434
435 if (shapeOptions.type === 'path') {
436 pathIn = shapeOptions.path;
437 } else {
438 x0 = xPixelSized ? shapeOptions.x0 : x2p(shapeOptions.x0);
439 y0 = yPixelSized ? shapeOptions.y0 : y2p(shapeOptions.y0);
440 x1 = xPixelSized ? shapeOptions.x1 : x2p(shapeOptions.x1);
441 y1 = yPixelSized ? shapeOptions.y1 : y2p(shapeOptions.y1);
442 }
443
444 if (x0 < x1) {
445 w0 = x0;
446 optW = 'x0';
447 e0 = x1;
448 optE = 'x1';
449 } else {
450 w0 = x1;
451 optW = 'x1';
452 e0 = x0;
453 optE = 'x0';
454 }
455
456 // For fixed size shapes take opposing direction of y-axis into account.
457 // Hint: For data sized shapes this is done by the y2p function.
458 if ((!yPixelSized && y0 < y1) || (yPixelSized && y0 > y1)) {
459 n0 = y0;
460 optN = 'y0';
461 s0 = y1;
462 optS = 'y1';
463 } else {
464 n0 = y1;
465 optN = 'y1';
466 s0 = y0;
467 optS = 'y0';
468 }
469
470 // setup dragMode and the corresponding handler
471 updateDragMode(evt);
472 renderVisualCues(shapeLayer, shapeOptions);
473 deactivateClipPathTemporarily(shapePath, shapeOptions, gd);
474 dragOptions.moveFn = dragMode === 'move' ? moveShape : resizeShape;
475 dragOptions.altKey = evt.altKey;
476 }
477
478 function endDrag() {
479 if (shouldSkipEdits(gd)) return;

Callers

nothing calls this directly

Calls 6

shouldSkipEditsFunction · 0.85
updateDragModeFunction · 0.85
renderVisualCuesFunction · 0.85
x2pFunction · 0.70
y2pFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…