Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Instrument window bug #12

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/Instrument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ const InstrumentFrame: React.FC<InstrumentFrameProps> = memo(forwardRef(
)}
/>
);
}),
);
},
));

export const Instrument: React.FC<Element> = ({ uuid, name, element, x, y, width, height }) => {
export const Instrument: React.FC<Element> = ({ uuid, name, element, x, y, width, height, onMouseEnter, onMouseLeave }) => {
const iframeRef = useRef<HTMLIFrameElement>(null);
const containerRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -122,7 +122,7 @@ export const Instrument: React.FC<Element> = ({ uuid, name, element, x, y, width
element={{ uuid, name, element, x, y, width, height }}
x={e.clientX}
y={e.clientY}
/>
/>,
))
), [dispatch]);

Expand Down Expand Up @@ -152,6 +152,8 @@ export const Instrument: React.FC<Element> = ({ uuid, name, element, x, y, width
width,
height,
}}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
<div className="absolute bottom-full w-full box-content border-2 border-b-0 border-silver-800 bg-silver-800 rounded-t-xl">
<div className="absolute -top-0.5 w-full flex justify-center">
Expand Down
10 changes: 8 additions & 2 deletions src/pages/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ const CanvasLayer: React.FC = () => {
const project = useWorkspaceSelector((state: WorkspaceState) => state.project.active);
const dispatch = useWorkspaceDispatch();

const [transformDisabled, setTransformDisabled] = useState(false);

const dndContext = useDndContext();

return (
<TransformWrapper
disabled={dndContext.active !== null}
disabled={transformDisabled || dndContext.active !== null}
centerOnInit
minScale={0.25}
initialScale={0.5}
Expand All @@ -112,7 +114,11 @@ const CanvasLayer: React.FC = () => {
}}
>
{project?.config.elements?.map((props) => (
<Instrument {...props} />
<Instrument
{...props}
onMouseEnter={() => setTransformDisabled(true)}
onMouseLeave={() => setTransformDisabled(false)}
/>
))}
</div>
</TransformComponent>
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface Element {
height: number;
x: number;
y: number;
onMouseEnter?: () => void;
onMouseLeave?: () => void;
}

export interface AceConfig {
Expand Down