mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 07:03:59 +00:00
SYNC: diagram - persist scroll when zooming
This commit is contained in:
committed by
Diflow
parent
98ad518b5d
commit
f2570c97f3
@@ -40,4 +40,4 @@ export function chooseTopTables(tables: TableInfo[], count: number) {
|
|||||||
return sorted.slice(0, count);
|
return sorted.slice(0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DIAGRAM_ZOOMS = [0.1, 0.15, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2];
|
export const DIAGRAM_ZOOMS = [0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1, 1.25, 1.5, 1.75, 2];
|
||||||
|
|||||||
@@ -908,6 +908,20 @@
|
|||||||
domWrapper.scrollLeft -= x;
|
domWrapper.scrollLeft -= x;
|
||||||
domWrapper.scrollTop -= y;
|
domWrapper.scrollTop -= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const oldZoomKoefRef = createRef(value?.style?.zoomKoef || 1);
|
||||||
|
$: {
|
||||||
|
if (
|
||||||
|
domWrapper &&
|
||||||
|
value?.style?.zoomKoef != oldZoomKoefRef.get() &&
|
||||||
|
value?.style?.zoomKoef > 0 &&
|
||||||
|
oldZoomKoefRef.get() > 0
|
||||||
|
) {
|
||||||
|
domWrapper.scrollLeft = Math.round((domWrapper.scrollLeft / oldZoomKoefRef.get()) * value?.style?.zoomKoef);
|
||||||
|
domWrapper.scrollTop = Math.round((domWrapper.scrollTop / oldZoomKoefRef.get()) * value?.style?.zoomKoef);
|
||||||
|
}
|
||||||
|
oldZoomKoefRef.set(value?.style?.zoomKoef);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -926,7 +940,7 @@
|
|||||||
bind:this={domCanvas}
|
bind:this={domCanvas}
|
||||||
on:dragover={e => e.preventDefault()}
|
on:dragover={e => e.preventDefault()}
|
||||||
on:drop={handleDrop}
|
on:drop={handleDrop}
|
||||||
style={`width:${canvasWidth}px;height:${canvasHeight}px;
|
style={`width:${canvasWidth / zoomKoef}px;height:${canvasHeight / zoomKoef}px;
|
||||||
${settings?.customizeStyle && value?.style?.zoomKoef ? `zoom:${value?.style?.zoomKoef};` : ''}
|
${settings?.customizeStyle && value?.style?.zoomKoef ? `zoom:${value?.style?.zoomKoef};` : ''}
|
||||||
`}
|
`}
|
||||||
on:mousedown={e => {
|
on:mousedown={e => {
|
||||||
|
|||||||
Reference in New Issue
Block a user