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

Method _mousemove

js/src/PanZoom.ts:171–213  ·  view source on GitHub ↗
(mouse_pos)

Source from the content-addressed store, hash-verified

169 }
170
171 _mousemove(mouse_pos) {
172 if (this.active && this.model.get('allow_pan')) {
173 // If memory is set to true, intermediate positions between the
174 // last position of the mouse and the current one will be
175 // interpolated.
176 if (this.previous_pos === undefined) {
177 this.previous_pos = mouse_pos;
178 }
179 const mouse_delta = {
180 x: mouse_pos[0] - this.previous_pos[0],
181 y: mouse_pos[1] - this.previous_pos[1],
182 };
183 return this.scale_promises.then((scale_views) => {
184 ['x', 'y'].forEach((dimension) => {
185 scale_views[dimension].forEach((view: any, index) => {
186 if (view.scale.invert) {
187 // Categorical scales don't have an inversion.
188 const scale = view.scale
189 .copy()
190 .domain(this.domains_in_order[dimension][index]);
191 // convert the initial domain to pixel coordinates
192 const pixel_min = scale(
193 this.domains_in_order[dimension][index][0]
194 );
195 const pixel_max = scale(
196 this.domains_in_order[dimension][index][1]
197 );
198 // shift pixels, and convert to new domain
199 const domain_min = scale.invert(
200 pixel_min - mouse_delta[dimension]
201 );
202 const domain_max = scale.invert(
203 pixel_max - mouse_delta[dimension]
204 );
205 view.model.set('min', domain_min);
206 view.model.set('max', domain_max);
207 view.touch();
208 }
209 });
210 });
211 });
212 }
213 }
214
215 mousewheel() {
216 if (this.model.get('allow_zoom')) {

Callers 2

mousemoveMethod · 0.95
interacts.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected