Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max widths of certain breakpoints does not match any window BreakpointState #13719

Closed
datariomj opened this issue Oct 21, 2018 · 11 comments · Fixed by #13828
Closed

Max widths of certain breakpoints does not match any window BreakpointState #13719

datariomj opened this issue Oct 21, 2018 · 11 comments · Fixed by #13828
Assignees

Comments

@datariomj
Copy link

Bug, feature request, or proposal:

Bug: Max widths does not match any window BreakpointState

What is the expected behavior?

  • width of 599 should be true on BreakpointState.XSmall
  • width of 1279 should be true on BreakpointState.Medium
  • width of 1919 should be true on BreakpointState.Large

What is the current behavior?

  • width of 599 doesn't match any BreakpointState
  • width of 1279 doesn't match any BreakpointState
  • width of 1919 doesn't match any BreakpointState

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material2-issue-breakpoints-states

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: v7.0.0
Material: v7.0.0
Typescript: v3.1.3
OS: Windows 10
Browser: Version 69.0.3497.100 (Official Build) (64-bit)

Is there anything else we should know?

Please use the Open in New Window feature of stackblitz to view this issue.

@manklu
Copy link

manklu commented Oct 21, 2018

Media queries use the viewport, not the window size.

  @HostListener('window:resize', ['$event'])
  onResize(event) {
    this.windowWidth = window.innerWidth;
  }

@datariomj
Copy link
Author

datariomj commented Oct 21, 2018

Media queries use the viewport, not the window size.

  @HostListener('window:resize', ['$event'])
  onResize(event) {
    this.windowWidth = window.innerWidth;
  }

Ok thanks. The stackblitz code was updated, and all the states still returns false.

@manklu
Copy link

manklu commented Oct 21, 2018

For me it works. Have you tried a separate window? It's easier to change the size and observe the breakpoints.

@josephperrott
Copy link
Member

Can you provide a different reproduction? Using your stackblitz, it appears to work as expected:

ezgif-4-51198459566c

@josephperrott josephperrott self-assigned this Oct 22, 2018
@josephperrott josephperrott added the cannot reproduce The team is unable to reproduce this issue with the information provided label Oct 22, 2018
@datariomj
Copy link
Author

datariomj commented Oct 23, 2018

Tried this on another pc and it's working. I think the issue is if the scale of the display is not in 100%.
image
image

@manklu
Copy link

manklu commented Oct 23, 2018

You can also reproduce this with zoom to 150%.

If the unscaled width is 899px and you zoom to 150%, all values are false. Looks like a rounding problem to me.

899 / 1.5 = 599.33 which is greater than 599 and lower than 600.

Same with Firefox and Edge.

Edit: Seems to be an old problem.
http://damienclarke.me/code/posts/those-1px-gaps-between-media-queries-can-be-a-problem
twbs/bootstrap#19197

@manklu
Copy link

manklu commented Oct 23, 2018

@josephperrott
Until Media Queries Level 4 are available you can minimize the problem by using subpixel queries. Something like

@media (max-width: 599.999999999px) {
  .redfont {
    color: red;
  }
}

https://stackblitz.com/edit/angular-material2-issue-breakpoints-states-pf5zlw

@datariomj
Copy link
Author

datariomj commented Oct 23, 2018

Yep, thanks for the help. Closing this issue 👍

@manklu
Copy link

manklu commented Oct 23, 2018

@datariomj Leave it open since there is a possibility to minimize the problem.

@datariomj datariomj reopened this Oct 23, 2018
@datariomj
Copy link
Author

datariomj commented Oct 23, 2018

Reopened. Can we change the label to something else instead of cannot reproduce?

@josephperrott josephperrott added has pr and removed cannot reproduce The team is unable to reproduce this issue with the information provided labels Oct 26, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants