File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,15 @@ const useWorkspaceLoad = (props: ISTKProps) => {
3434 height : workspaceGroupHeight ,
3535 width : workspaceGroupWidth
3636 } = d3Extended . selectionBounds ( workspaceGroup ) ;
37- let scaleFactor = props . data ?. workspace ?. initialViewBoxScale ?? 1 ;
37+ let scaleFactor = 1 ;
38+ if ( props . data ?. workspace ?. initialViewBoxScale ) {
39+ scaleFactor = props . data ?. workspace ?. initialViewBoxScale ;
40+ if ( props . data ?. workspace ?. initialViewBoxScaleForWidth ) {
41+ const currentWidth = document . documentElement . clientWidth ;
42+ const ratio = currentWidth / props . data ?. workspace ?. initialViewBoxScaleForWidth ;
43+ scaleFactor *= ratio >= 1 ? ratio : ratio * 1.25 ;
44+ }
45+ }
3846 if ( props . data ?. workspace ?. visibilityOffset ) {
3947 workspaceGroup . attr ( dataAttributes . visibilityOffset , props . data ?. workspace . visibilityOffset ) ;
4048 }
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ const initialState = {
7676 polylines : [ ] ,
7777 images : [ ] ,
7878 initialViewBoxScale : null ,
79+ initialViewBoxScaleForWidth : document . documentElement . clientWidth ,
7980 visibilityOffset : 0
8081} ;
8182
@@ -247,6 +248,7 @@ export const slice = createSlice({
247248 } ,
248249 setInitialViewBoxScale : ( state , action ) => {
249250 state . initialViewBoxScale = action . payload ;
251+ state . initialViewBoxScaleForWidth = document . documentElement . clientWidth ;
250252 } ,
251253 setVisibilityOffset : ( state , action ) => {
252254 state . visibilityOffset = action . payload ;
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ export interface ISTKData {
5555 images ?: IImage [ ] ;
5656 workspace ?: {
5757 initialViewBoxScale ?: number ;
58+ initialViewBoxScaleForWidth ?: number ;
5859 visibilityOffset ?: number ;
5960 } ;
6061}
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ export const stateToJSON = () => {
106106 images : domImagesToJSON ( ) ,
107107 workspace : {
108108 initialViewBoxScale : state . initialViewBoxScale ,
109+ initialViewBoxScaleForWidth : state . initialViewBoxScaleForWidth ,
109110 visibilityOffset : state . visibilityOffset
110111 }
111112 } ;
You can’t perform that action at this time.
0 commit comments