MCPcopy Index your code
hub / github.com/bqplot/bqplot / on_drag

Function on_drag

js/src/ScatterBase.ts:663–696  ·  view source on GitHub ↗
(d, i, dragged_node)

Source from the content-addressed store, hash-verified

661 }
662
663 on_drag(d, i, dragged_node) {
664 const x_scale = this.scales.x,
665 y_scale = this.scales.y;
666 // If restrict_x is true, then the move is restricted only to the X
667 // direction.
668 const restrict_x = this.model.get('restrict_x'),
669 restrict_y = this.model.get('restrict_y');
670 if (restrict_x && restrict_y) {
671 return;
672 }
673 if (!restrict_y) {
674 d[0] = d3GetEvent().x;
675 }
676 if (!restrict_x) {
677 d[1] = d3GetEvent().y;
678 }
679
680 d3.select(dragged_node).attr('transform', () => {
681 return 'translate(' + d[0] + ',' + d[1] + ')';
682 });
683 this.send({
684 event: 'drag',
685 origin: { x: d.x, y: d.y },
686 point: {
687 x: x_scale.invert(d[0]),
688 y: y_scale.invert(d[1]),
689 },
690 index: i,
691 });
692 if (this.model.get('update_on_move')) {
693 // saving on move if flag is set
694 this.update_array(d, i);
695 }
696 }
697
698 drag_ended(d, i, dragged_node) {
699 const x_scale = this.scales.x,

Callers

nothing calls this directly

Calls 2

d3GetEventFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…