Tablet formFactor

Hello,

wixWindow.formFactor returns ‘Desktop’ rather than ‘Tablet’ on Safari for iPad. Is there another way of identifying that the device is a tablet?

Any help gratefully received.

Many thanks,

Luke

On Classic Editor, Tablet usually display Desktop view, (or the tablet browser defaults to Desktop view) so it returns desktop.

You can use getBoundingRect( ) to have greater control.

Does it works?

I thought it should return Tablet in this case.
Anyway, as an alternative, you can add an iframe (or a custom element) to the page and retrieve the device type from the user agent (google it). then post it from the iframe to the parent page and continue from there.

I also had a problem with this. I ended up just making my own function for it using getBoundingRect()

import wixWindow from 'wix-window';

export function formFactor() {
       return wixWindow.getBoundingRect()
        .then((windowSizeInfo) => {
            if (windowSizeInfo.window.width < 751) {
                return "Mobile"
            }
            else
                if (windowSizeInfo.window.width < 1001) {
                    return "Tablet"
                }
                else
                    return "Desktop"
        })
}

But this way you can’t know if it is a tablet or maybe a desktop with the browser window not being maximized on load (to distinct between these 2 options, you’ll go for the user agent solution).

Thanks all for the responses. I went for the user agent solution. Full of useful information!