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

Make update dialogs zoom aware #338

Closed
Closed
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
3 changes: 2 additions & 1 deletion src/main/components/controls/popover/popover-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const PopoverContainer = styled.div<Props>`
max-width: 276px;
position: absolute;
text-align: left;
text-align: start;
text-decoration: none;
text-transform: none;
text-shadow: none;
Expand All @@ -30,6 +29,7 @@ export const PopoverContainer = styled.div<Props>`
word-break: normal;
word-spacing: normal;
word-wrap: break-word;
transform-origin: top left;

*,
*:before,
Expand All @@ -41,6 +41,7 @@ export const PopoverContainer = styled.div<Props>`
let x = `${props.position.x}px`;
let y = `${props.position.y}px`;
const alignment = props.alignment === 'start' ? 0 : props.alignment === 'end' ? 100 : 50;

switch (props.placement) {
case 'top':
x += ` - ${alignment}%`;
Expand Down
1 change: 1 addition & 0 deletions src/main/components/controls/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Props = {
alignment?: 'start' | 'center' | 'end';
position: { x: number; y: number };
maxHeight?: number;
zoomFactor: number;
} & HTMLAttributes<HTMLDivElement>;

export const Popover = forwardRef<HTMLDivElement, Props>(
Expand Down
12 changes: 11 additions & 1 deletion src/main/components/update-pane/update-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type StateProps = {
element: IUMLElement | null;
disabled: boolean;
mode: ApollonMode;
zoomFactor: number;
};

type DispatchProps = {
Expand All @@ -42,6 +43,7 @@ const enhance = compose<ComponentClass<OwnProps>>(
element: state.elements[state.updating[0]],
disabled: !state.editor.enablePopups,
mode: state.editor.mode,
zoomFactor: state.editor.zoomFactor,
}),
{
updateEnd: UMLElementRepository.updateEnd,
Expand Down Expand Up @@ -92,7 +94,14 @@ class UnwrappedUpdatePane extends Component<Props, State> {
}

return createPortal(
<Popover ref={this.popover} position={position} placement={placement} alignment={alignment} maxHeight={500}>
<Popover
ref={this.popover}
position={position}
placement={placement}
alignment={alignment}
maxHeight={500}
zoomFactor={this.props.zoomFactor}
>
<CustomPopupComponent element={element} />
</Popover>,
this.props.root,
Expand Down Expand Up @@ -130,6 +139,7 @@ class UnwrappedUpdatePane extends Component<Props, State> {
const absolute: Point = this.props
// relative to drawing area (0,0)
.getAbsolutePosition(element.id)
.scale(this.props.zoomFactor)
.add(
canvas
.origin()
Expand Down
Loading