feat(config): Add activateViewportBeforeInteraction parameter for viewport interaction customization (#3847)
This commit is contained in:
1 parent
805c53270f
commit
f707b4ebc9
11 files changed
+2843
-3567
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import React, { useEffect, useCallback } from 'react';
|
||||
import React, {useEffect, useCallback, useMemo} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { ServicesManager, Types, MeasurementService } from '@ohif/core';
|
||||
import { ViewportGrid, ViewportPane, useViewportGrid } from '@ohif/ui';
|
||||
import EmptyViewport from './EmptyViewport';
|
||||
import classNames from 'classnames';
|
||||
import { useAppConfig } from '@state';
|
||||
|
||||
function ViewerViewportGrid(props) {
|
||||
const { servicesManager, viewportComponents, dataSource } = props;
|
||||
@@ -17,6 +18,18 @@ function ViewerViewportGrid(props) {
|
||||
servicesManager as ServicesManager
|
||||
).services;
|
||||
|
||||
/**
|
||||
* Determine whether users need to use the tools directly, or whether they need to click once to activate the viewport before using tools.
|
||||
* If 'activateViewportBeforeInteraction' is available in the 'window.config' object, use its value;
|
||||
* otherwise, default to true.
|
||||
* If true, users need to click once to activate the viewport before using the tools.
|
||||
* if false, tools can be used directly.
|
||||
*/
|
||||
const activateViewportBeforeInteraction = useMemo(() => {
|
||||
const [appConfig] = useAppConfig();
|
||||
return appConfig?.activateViewportBeforeInteraction ?? true;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* This callback runs after the viewports structure has changed in any way.
|
||||
* On initial display, that means if it has changed by applying a HangingProtocol,
|
||||
@@ -311,7 +324,7 @@ function ViewerViewportGrid(props) {
|
||||
<div
|
||||
data-cy="viewport-pane"
|
||||
className={classNames('flex h-full w-full flex-col', {
|
||||
'pointer-events-none': !isActive,
|
||||
'pointer-events-none': !isActive && activateViewportBeforeInteraction,
|
||||
})}
|
||||
>
|
||||
<ViewportComponent
|
||||
|
||||
Reference in new issue
Block a user