File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ export const MiniMap: React.FC<MiniMapProps> = ({
5151 const wrapperRef = useRef < HTMLDivElement | null > ( null ) ;
5252 const previewRef = useRef < HTMLDivElement | null > ( null ) ;
5353
54+ const getViewportSize = useCallback ( ( ) => {
55+ if ( instance . wrapperComponent ) {
56+ const rect = instance . wrapperComponent . getBoundingClientRect ( ) ;
57+
58+ return {
59+ width : rect . width ,
60+ height : rect . height
61+ } ;
62+ }
63+ return {
64+ width : 0 ,
65+ height : 0
66+ } ;
67+ } , [ instance . wrapperComponent ] ) ;
68+
5469 const getContentSize = useCallback ( ( ) => {
5570 if ( instance . contentComponent ) {
5671 const rect = instance . contentComponent . getBoundingClientRect ( ) ;
@@ -116,7 +131,7 @@ export const MiniMap: React.FC<MiniMapProps> = ({
116131 mainRef . current . style . height = `${ miniSize . height } px` ;
117132 }
118133 if ( previewRef . current ) {
119- const size = getContentSize ( ) ;
134+ const size = getViewportSize ( ) ;
120135 const scale = computeMiniMapScale ( ) ;
121136 const previewScale = scale * ( 1 / instance . transformState . scale ) ;
122137 const transform = instance . handleTransformStyles (
You can’t perform that action at this time.
0 commit comments