Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Mobile / tablet dectection #84

Open
rochejul opened this issue Oct 3, 2012 · 0 comments
Open

Mobile / tablet dectection #84

rochejul opened this issue Oct 3, 2012 · 0 comments

Comments

@rochejul
Copy link

rochejul commented Oct 3, 2012

Hi,

A fancy enhancement will to include a detection of the device and put it into M.Environment.

We could have: isDeviceMobile or isDeviceTablet.

Here the following code:

M.Environment = M.Object.extend(
{
isDeviceMobile: function() {
if(window.matchMedia("(orientation:landscape)").matches){
return window.matchMedia("(max-height:640px)").matches;
}

        return window.matchMedia("(max-width:640px)").matches;
    },
    isDeviceTablet: function() {
        return !this.isDeviceMobile();
    }
}

);

Cheers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant