Skip to content

Commit 0564e3d

Browse files
author
Alexis Girault
committed
feat(RenderWindowInteractor): trigger start/endMouseMove events
1 parent e1f0521 commit 0564e3d

File tree

1 file changed

+16
-1
lines changed
  • Sources/Rendering/Core/RenderWindowInteractor

1 file changed

+16
-1
lines changed

Sources/Rendering/Core/RenderWindowInteractor/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const deviceInputMap = {
2121

2222
const handledEvents = [
2323
'Animation',
24+
'StartMouseMove',
2425
'MouseMove',
26+
'EndMouseMove',
2527
'LeftButtonPress',
2628
'LeftButtonRelease',
2729
'MiddleButtonPress',
@@ -352,7 +354,19 @@ function vtkRenderWindowInteractor(publicAPI, model) {
352354
};
353355
const keys = getModifierKeysFor(event);
354356
Object.assign(callData, keys);
355-
publicAPI.mouseMoveEvent(callData);
357+
358+
if (model.moveTimeoutID === 0) {
359+
publicAPI.startMouseMoveEvent(callData);
360+
} else {
361+
publicAPI.mouseMoveEvent(callData);
362+
clearTimeout(model.moveTimeoutID);
363+
}
364+
365+
// start a timer to keep us animating while we get mouse move events
366+
model.moveTimeoutID = setTimeout(() => {
367+
publicAPI.endMouseMoveEvent();
368+
model.moveTimeoutID = 0;
369+
}, 200);
356370
};
357371

358372
publicAPI.handleAnimation = () => {
@@ -843,6 +857,7 @@ const DEFAULT_VALUES = {
843857
requestAnimationCount: 0,
844858
lastFrameTime: 0.1,
845859
wheelTimeoutID: 0,
860+
moveTimeoutID: 0,
846861
lastGamepadValues: {},
847862
};
848863

0 commit comments

Comments
 (0)