action on ViewportPanes for setting the active viewport
This commit is contained in:
parent
30caec0043
commit
9b75d95e48
@ -10,7 +10,10 @@ function ViewportPane({
|
|||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
isActive,
|
isActive,
|
||||||
|
onClick,
|
||||||
onDrop,
|
onDrop,
|
||||||
|
onScroll,
|
||||||
|
onWheel,
|
||||||
acceptDropsFor,
|
acceptDropsFor,
|
||||||
}) {
|
}) {
|
||||||
const [{ isHovered, isHighlighted }, drop] = useDrop({
|
const [{ isHovered, isHighlighted }, drop] = useDrop({
|
||||||
@ -34,6 +37,14 @@ function ViewportPane({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={drop}
|
ref={drop}
|
||||||
|
// onInteraction...
|
||||||
|
// https://reactjs.org/docs/events.html#mouse-events
|
||||||
|
// https://stackoverflow.com/questions/8378243/catch-scrolling-event-on-overflowhidden-element
|
||||||
|
// setActiveViewport
|
||||||
|
onClick={onClick}
|
||||||
|
onScroll={onScroll}
|
||||||
|
onWheel={onWheel}
|
||||||
|
onSc
|
||||||
className={classnames(
|
className={classnames(
|
||||||
'rounded-lg hover:border-primary-light transition duration-300 outline-none overflow-hidden',
|
'rounded-lg hover:border-primary-light transition duration-300 outline-none overflow-hidden',
|
||||||
{
|
{
|
||||||
@ -57,8 +68,19 @@ ViewportPane.propTypes = {
|
|||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
/** Indicates drag items we should accept for drops */
|
/** Indicates drag items we should accept for drops */
|
||||||
acceptDropsFor: PropTypes.string.isRequired,
|
acceptDropsFor: PropTypes.string.isRequired,
|
||||||
|
onClick: PropTypes.func,
|
||||||
/** Function that handles drop events */
|
/** Function that handles drop events */
|
||||||
onDrop: PropTypes.func.isRequired,
|
onDrop: PropTypes.func.isRequired,
|
||||||
|
onScroll: PropTypes.func,
|
||||||
|
onWheel: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const noop = () => {};
|
||||||
|
|
||||||
|
ViewportPane.defaultProps = {
|
||||||
|
onClick: noop,
|
||||||
|
onScroll: noop,
|
||||||
|
onWheel: noop,
|
||||||
|
}
|
||||||
|
|
||||||
export default ViewportPane;
|
export default ViewportPane;
|
||||||
|
|||||||
@ -54,8 +54,8 @@ function App({ config, defaultExtensions }) {
|
|||||||
console.log(state, action);
|
console.log(state, action);
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'DO_TODO':
|
case 'SET_ACTIVE_VIEWPORT_INDEX':
|
||||||
return state;
|
return { ...state, ...{ activeViewportIndex: action.payload } };
|
||||||
default:
|
default:
|
||||||
return action.payload;
|
return action.payload;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,9 @@ function ViewerViewportGrid(props) {
|
|||||||
{ numCols, numRows, activeViewportIndex, viewports },
|
{ numCols, numRows, activeViewportIndex, viewports },
|
||||||
dispatch,
|
dispatch,
|
||||||
] = useViewportGrid();
|
] = useViewportGrid();
|
||||||
|
const setActiveViewportIndex = index => {
|
||||||
|
dispatch({ type: 'SET_ACTIVE_VIEWPORT_INDEX', payload: index });
|
||||||
|
}
|
||||||
|
|
||||||
// TODO -> Need some way of selecting which displaySets hit the viewports.
|
// TODO -> Need some way of selecting which displaySets hit the viewports.
|
||||||
const { DisplaySetService } = servicesManager.services;
|
const { DisplaySetService } = servicesManager.services;
|
||||||
@ -97,6 +100,9 @@ function ViewerViewportGrid(props) {
|
|||||||
className="m-1"
|
className="m-1"
|
||||||
acceptDropsFor="displayset"
|
acceptDropsFor="displayset"
|
||||||
onDrop={onDropHandler}
|
onDrop={onDropHandler}
|
||||||
|
onScroll={() => { setActiveViewportIndex(viewportIndex); }}
|
||||||
|
onClick={() => { setActiveViewportIndex(viewportIndex); }}
|
||||||
|
onWheel={() => { setActiveViewportIndex(viewportIndex); }}
|
||||||
isActive={activeViewportIndex === viewportIndex}
|
isActive={activeViewportIndex === viewportIndex}
|
||||||
>
|
>
|
||||||
<EmptyViewport />
|
<EmptyViewport />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user