This method allows you to dynamically change the height of the IFrame window in which the mini-application is open,
adjusting to the size of the user's browser.
Platforms
- B2B-Web
Method params
Parameter name | Parameter type | Required | Parameter description |
---|---|---|---|
height | number | yes | Height of window to be set |
Return value
После успешного выполнения метод вернет назад объект с текущей высотой окна, которая будет совпадать с отправленной:
json{ "height": 700 }
Automatic resizing of the mini-application window
To adjust the window size dynamically we recommend using ResizeObserver.
Below is an example of a React component that wraps the application and uses ResizeObserver to automatically resize the IFrame:
typescriptimport React, { useEffect } from 'react' import bridge from '@open-condo/bridge' type AppContentWrapperProps = { children?: React.ReactNode } export const AppContentWrapper: React.FC<AppContentWrapperProps> = ({ children }) => { useEffect(() => { if (typeof document !== 'undefined') { const observer = new ResizeObserver((entries) => { if (entries && entries.length) { bridge.send('CondoWebAppResizeWindow', { height: entries[0].target.clientHeight }) } }) observer.observe(document.body) return () => observer.unobserve(document.body) } }, []) return ( <> {children} </> ) }