Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { getEnabledElement, triggerEvent } from '@cornerstonejs/core'; import normalizeWheel from './normalizeWheel'; import Events from '../../enums/Events'; // ~~ VIEWPORT LIBRARY import getMouseEventPoints from '../mouse/getMouseEventPoints'; import { MouseWheelEventDetail } from '../../types/EventTypes'; /** * wheelListener - Captures and normalizes mouse wheel events. Emits as a * cornerstoneTools3D mouse wheel event. * @param evt - The mouse wheel event. */ function wheelListener(evt: WheelEvent) { const element = <HTMLDivElement>evt.currentTarget; const enabledElement = getEnabledElement(element); const { renderingEngineId, viewportId } = enabledElement; // Prevent triggering MouseWheel events that are not real scroll events: // E.g. when clicking the MiddleMouseWheelButton, a deltaY of 0 is emitted. // See https://github.com/cornerstonejs/cornerstoneTools/issues/935 Iif (evt.deltaY > -1 && evt.deltaY < 1) { return; } evt.preventDefault(); const { spinX, spinY, pixelX, pixelY } = normalizeWheel(evt); const direction = spinY < 0 ? -1 : 1; const eventDetail: MouseWheelEventDetail = { event: evt, eventName: Events.MOUSE_WHEEL, renderingEngineId, viewportId, element, camera: {}, detail: evt, wheel: { spinX, spinY, pixelX, pixelY, direction, }, points: getMouseEventPoints(evt), }; triggerEvent(element, Events.MOUSE_WHEEL, eventDetail); } export default wheelListener; |