-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Feature Suggestion
Add the possibility to set the defaultBreakpoint dynamically when using nuxt module.
Why?
To prevent misbehavior of components when reloading a page in a screen size that is not the default. Components that depends on $mq are wrongly shown or hidden while vue-mq is not fully loaded in the frontend application, causing a blink of very misplaced ui components for a few seconds.
Suggested solution
With SSR it's possible to have a header telling the screen size of origin request. We could have something like:
/**
* nuxt-mq
*/
mq: {
defaultBreakpoint: (req) => {
if (req.headers['CloudFront-Is-Mobile-Viewer']) {
return 'modernPhone';
}
if (req.headers['CloudFront-Is-Tablet-Viewer']) {
return 'tablet';
}
return 'desktop';
},
breakpoints: {
oldPhone: 375, // 0 ~ 374
modernPhone: 800, // 375 ~ 799
tablet: 1000, // 800 ~ 999
notebook: 1200, // 1100 ~ 1199
desktop: Infinity, // 1300+
},
},Mattymoo007
Metadata
Metadata
Assignees
Labels
No labels