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

Breakpoint: Opt-in exact sizes #10

Open
brigand opened this issue Nov 15, 2017 · 0 comments
Open

Breakpoint: Opt-in exact sizes #10

brigand opened this issue Nov 15, 2017 · 0 comments

Comments

@brigand
Copy link
Owner

brigand commented Nov 15, 2017

Sometimes you need the exact size of the viewport in one or more breakpoints. This may only be needed for e.g. your 'small' size, where you do some computed styles.

{ name: 'small', maxWidth: 600, passExact: true }

Then in your component, you can do bp.width() to get the viewport width, and bp.height() to get the viewport height. If passExact is falsy for the current breakpoint, then the width and height methods will throw.

The breakpoint accepts any of these properties:

  • throttle: number milliseconds to wait between updates
  • raf: boolean use requestAnimationFrame to throttle updates
  • idle: number, use requestIdleCallback. The number is the max timeout before an update occurs.

For idle on a viewport breakpoint, it'll generally happen when the user pauses resizing. It's a bit inconsistent. For an element resizing when not based on user interaction, it's highly unstable. I recommend setting this to reasonably low value, like 50 to 250. That cuts down on the inconsistency a bit. Even with a long duration, basic tests show it's called quickly in chrome.

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

No branches or pull requests

1 participant