File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ import {
5656 SheetType ,
5757 PartDrillDown ,
5858 PartDrillDownInfo ,
59+ Adaptive ,
5960} from '@/components' ;
6061
6162import './index.less' ;
@@ -148,7 +149,7 @@ function MainLayout() {
148149 const [ showTotals , setShowTotals ] = React . useState ( false ) ;
149150 const [ themeCfg , setThemeCfg ] = React . useState < ThemeCfg > ( { name : 'default' } ) ;
150151 const [ showCustomTooltip , setShowCustomTooltip ] = React . useState ( false ) ;
151- const [ adaptive , setAdaptive ] = React . useState ( false ) ;
152+ const [ adaptive , setAdaptive ] = React . useState < Adaptive > ( true ) ;
152153 const [ options , setOptions ] =
153154 React . useState < Partial < S2Options < React . ReactNode > > > ( defaultOptions ) ;
154155 const [ dataCfg , setDataCfg ] =
@@ -563,7 +564,7 @@ function MainLayout() {
563564 < Switch
564565 checkedChildren = "容器宽高自适应开"
565566 unCheckedChildren = "容器宽高自适应关"
566- defaultChecked = { adaptive }
567+ defaultChecked = { Boolean ( adaptive ) }
567568 onChange = { setAdaptive }
568569 />
569570 < Switch
Original file line number Diff line number Diff line change @@ -52,15 +52,22 @@ export const useResize = (params: UseResizeEffectParams) => {
5252 return ;
5353 }
5454 const resizeObserver = new ResizeObserver (
55- debounce ( ( [ entry ] = [ ] ) => {
55+ debounce ( ( [ entry ] : ResizeObserverEntry [ ] = [ ] ) => {
5656 if ( entry ) {
5757 const [ size ] = entry . borderBoxSize || [ ] ;
58+
59+ // Safari 不支持 borderBoxSize 属性
5860 const width = adaptiveWidth
59- ? Math . floor ( size ?. inlineSize )
61+ ? Math . floor (
62+ ( size ?. inlineSize || entry . contentRect ?. width ) ?? optionWidth ,
63+ )
6064 : optionWidth ;
6165 const height = adaptiveHeight
62- ? Math . floor ( container ?. getBoundingClientRect ( ) . height ) // 去除 header 和 page 后才是 sheet 真正的高度
66+ ? Math . floor (
67+ container ?. getBoundingClientRect ( ) . height ?? optionHeight ,
68+ ) // 去除 header 和 page 后才是 sheet 真正的高度
6369 : optionHeight ;
70+
6471 if ( ! adaptiveWidth && ! adaptiveHeight ) {
6572 return ;
6673 }
You can’t perform that action at this time.
0 commit comments