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

Function updateDragMode

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

Source from the content-addressed store, hash-verified

384 }
385
386 function updateDragMode(evt) {
387 if (shouldSkipEdits(gd)) {
388 dragMode = null;
389 return;
390 }
391
392 if (isLine) {
393 if (evt.target.tagName === 'path') {
394 dragMode = 'move';
395 } else {
396 dragMode =
397 evt.target.attributes['data-line-point'].value === 'start-point'
398 ? 'resize-over-start-point'
399 : 'resize-over-end-point';
400 }
401 } else {
402 // element might not be on screen at time of setup,
403 // so obtain bounding box here
404 var dragBBox = dragOptions.element.getBoundingClientRect();
405
406 // choose 'move' or 'resize'
407 // based on initial position of cursor within the drag element
408 var w = dragBBox.right - dragBBox.left;
409 var h = dragBBox.bottom - dragBBox.top;
410 var x = evt.clientX - dragBBox.left;
411 var y = evt.clientY - dragBBox.top;
412 var cursor =
413 !isPath && w > MINWIDTH && h > MINHEIGHT && !evt.shiftKey
414 ? dragElement.getCursor(x / w, 1 - y / h)
415 : 'move';
416
417 setCursor(shapePath, cursor);
418
419 // possible values 'move', 'sw', 'w', 'se', 'e', 'ne', 'n', 'nw' and 'w'
420 dragMode = cursor.split('-')[0];
421 }
422 }
423
424 function startDrag(evt) {
425 if (shouldSkipEdits(gd)) return;

Callers 1

startDragFunction · 0.85

Calls 1

shouldSkipEditsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…