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

Method mousemove

js/src/FastIntervalSelector.ts:91–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89 }
90
91 mousemove() {
92 if (this.freeze_dont_move || !this.active) {
93 return;
94 }
95 this.dirty = true;
96 const mouse_pos = d3.mouse(this.background.node());
97 const int_len =
98 this.size > 0 ? this.size : parseInt(this.rect.attr('width'));
99 const vert_factor = (this.height - mouse_pos[1]) / this.height;
100 const interval_size = this.freeze_but_move
101 ? int_len
102 : Math.round(vert_factor * this.width);
103
104 let start;
105 if (mouse_pos[0] - interval_size / 2 < 0) {
106 start = 0;
107 } else if (mouse_pos[0] + interval_size / 2 > this.width) {
108 start = this.width - interval_size;
109 } else {
110 start = mouse_pos[0] - interval_size / 2;
111 }
112
113 //update the interval location and size
114 this.rect.attr('x', start);
115 this.rect.attr('width', interval_size);
116 const pixel_extent: [number, number] = [start, start + interval_size];
117 this.set_selected('selected', this.scale.invertRange(pixel_extent));
118 this.update_mark_selected(pixel_extent, undefined);
119 this.touch();
120 this.dirty = false;
121 }
122
123 update_mark_selected(extent_x, extent_y) {
124 if (extent_x === undefined || extent_x.length === 0) {

Callers

nothing calls this directly

Calls 1

update_mark_selectedMethod · 0.95

Tested by

no test coverage detected