Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Illogical behaviour of $mdMedia – what should happen at 600, 960? #3423

Closed
@typeofweb

Description

@typeofweb

I think the behaviour of $mdMedia service is illogical and inconsistent with CSS media queries.

Take a look at $mdConstant:

MEDIA: {
  'sm': '(max-width: 600px)',
  'gt-sm': '(min-width: 600px)',
  'md': '(min-width: 600px) and (max-width: 960px)',
  'gt-md': '(min-width: 960px)',
  'lg': '(min-width: 960px) and (max-width: 1200px)',
  'gt-lg': '(min-width: 1200px)'
},

It seems illogical that sm and gt-sm are both true at 600px. The same for md and gt-md at 960px, and lg and gt-lg at 1200px. So this layout will break at 600px:

<div ng-if="$mdMedia('sm')">content for mobile</div>
<div ng-if="$mdMedia('gt-sm')">content for other devices</div>

Moreover, this behaviour is inconsistent with CSS media queries:

@media (max-width: 599px) { ... }
@media (min-width: 600px) { ... }
@media (min-width: 600px) and (max-width: 959px) { ... }
@media (min-width: 960px) { ... }
@media (min-width: 960px) and (max-width: 1199px) { ... }
@media (min-width: 1200px) { ... }

Is there any good reason for that? I suggest we fix it so $mdMedia('sm') and $mdMedia('gt-sm') won't return true at the same time. What are your thoughts?
I can make a pull request once we agree on the solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions