mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 23:01:29 +03:00
79a6a6a1c0
When the CB is opened, pan to show it. Large screen: <video src="https://github.com/enso-org/enso/assets/1047859/1a07c8cc-5818-420a-9fb3-1d1cb308cb87"> Small screen: <video src="https://github.com/enso-org/enso/assets/1047859/a9f18df5-c0ca-426c-959a-bda5cd077541"> # Important Notes A prioritized-coordinates approach is used to adjust panning goals based on screen space: - Fitting the input area is highest-priority. - If possible, the whole component panel area will be fit. - If possible, the visualization preview will be fit. - If there's extra room, margins will be included; the top and left are prioritized because those margins prevent overlap with fixed UI elements.
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import type { GraphSelection } from '@/providers/graphSelection'
|
|
import type { GraphNavigator } from '../src/providers/graphNavigator'
|
|
import { Rect } from '../src/util/data/rect'
|
|
import { Vec2 } from '../src/util/data/vec2'
|
|
|
|
export const graphNavigator: GraphNavigator = {
|
|
events: {} as any,
|
|
clientToScenePos: () => Vec2.Zero,
|
|
clientToSceneRect: () => Rect.Zero,
|
|
panAndZoomTo: () => {},
|
|
panTo: () => {},
|
|
transform: '',
|
|
prescaledTransform: '',
|
|
translate: Vec2.Zero,
|
|
targetScale: 1,
|
|
scale: 1,
|
|
sceneMousePos: Vec2.Zero,
|
|
viewBox: '',
|
|
viewport: Rect.Zero,
|
|
}
|
|
|
|
export function graphNavigatorWith(modifications?: Partial<GraphNavigator>): GraphNavigator {
|
|
return Object.assign({}, graphNavigator, modifications)
|
|
}
|
|
|
|
export const graphSelection: GraphSelection = {
|
|
events: {} as any,
|
|
anchor: undefined,
|
|
deselectAll: () => {},
|
|
handleSelectionOf: () => {},
|
|
setSelection: () => {},
|
|
hoveredNode: undefined,
|
|
hoveredPort: undefined,
|
|
isSelected: () => false,
|
|
isChanging: false,
|
|
mouseHandler: () => false,
|
|
selectAll: () => {},
|
|
selected: new Set(),
|
|
}
|
|
|
|
export function graphSelectionWith(modifications?: Partial<GraphSelection>): GraphSelection {
|
|
return Object.assign({}, graphSelection, modifications)
|
|
}
|
|
|
|
export const all = {
|
|
'graph navigator': graphNavigator,
|
|
'graph selection': graphSelection,
|
|
}
|
|
|
|
export function allWith(
|
|
modifications: Partial<{ [K in keyof typeof all]: Partial<(typeof all)[K]> }>,
|
|
): typeof all {
|
|
return {
|
|
'graph navigator': graphNavigatorWith(modifications['graph navigator']),
|
|
'graph selection': graphSelectionWith(modifications['graph selection']),
|
|
}
|
|
}
|