@@ -55,6 +55,7 @@ export const STORAGE_KEY = 'sidebar';
5555
5656// the maximum width, after which the full-width content does not grow
5757export const MAX_WIDTH = 1800 ;
58+ export const ULTRA_WIDE_DEFAULT = 500 ;
5859
5960export const eventsMap = {
6061 touch: {
@@ -99,19 +100,25 @@ export default {
99100 },
100101 },
101102 data () {
103+ const windowWidth = window .innerWidth ;
104+ const breakpoint = BreakpointName .large ;
102105 // get the min width, in case we dont have a previously saved value
103- const fallback = calcWidthPercent (minWidthResponsivePercents[BreakpointName .large ]);
104- // computed is not ready yet in `data`.
106+ const minWidth = calcWidthPercent (minWidthResponsivePercents[breakpoint]);
107+ // calc the maximum width
108+ const maxWidth = calcWidthPercent (maxWidthResponsivePercents[breakpoint]);
109+ // have a default width for very large screens, or use half of the min and max
110+ const defaultWidth = windowWidth >= MAX_WIDTH
111+ ? ULTRA_WIDE_DEFAULT
112+ : Math .round ((minWidth + maxWidth) / 2 );
113+ // get the already stored data, fallback to a default one.
114+ const storedWidth = storage .get (STORAGE_KEY , defaultWidth);
105115 return {
106116 isDragging: false ,
107- width: Math .min (
108- storage .get (STORAGE_KEY , fallback),
109- // calc the maximum width
110- calcWidthPercent (maxWidthResponsivePercents[BreakpointName .large ]),
111- ),
117+ // limit the width to a range
118+ width: Math .min (Math .max (storedWidth, minWidth), maxWidth),
112119 isTouch: false ,
113- windowWidth: window . innerWidth ,
114- breakpoint: BreakpointName . large ,
120+ windowWidth,
121+ breakpoint,
115122 noTransition: false ,
116123 focusTrapInstance: null ,
117124 };
0 commit comments