How to implement transition of widget to the mobile layout

When initializing the widget, you can specify whether to use the mobile version by default. To do this, use the isMobile parameter of the window.metaframe.create method.

To switch between the mobile and desktop layouts of Metaframe depending on the device screen resolution, use the window.metaframe.setIsMobile method.

Example code for switching to mobile layout of Metaframe at a screen resolution of 1000 px and less:

Copy
Full screen
Small screen
const mediaQuery = window.matchMedia("(max-width: 1000px)");

function handleMetaframeLayoutChange(e) {
window.metaframe.setIsMobile(e.matches);
}

mediaQuery.addEventListener('change', handleMetaframeLayoutChange)
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: October 9, 2024

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!