-
Notifications
You must be signed in to change notification settings - Fork 42
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
Allow use of breakpoints instead of user-agent sniffing #41
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** @desc Utility class that determines the breakpoint based on window width. **/ | ||
import MobileDetection from './mobile'; | ||
|
||
export class BreakpointDetection { | ||
/** | ||
* @desc Constructor. | ||
* @param {number} desktopBreakpoint The minimum width at which the browser is considered desktop. | ||
**/ | ||
constructor(desktopBreakpoint) { | ||
this.desktopBreakpoint = desktopBreakpoint; | ||
} | ||
|
||
/** | ||
* @desc Determines if the user is using a Retina display. | ||
**/ | ||
Retina() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you adding a retina option if you don't use it anywhere? |
||
return MobileDetection.Retina(); | ||
} | ||
|
||
/** | ||
* @desc Determines if the user is using a mobile device. | ||
**/ | ||
any() { | ||
return (window.innerWidth < this.desktopBreakpoint); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a more descriptive function name. Also what happens if the window isn't available -- you should check for the window !== undefined. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also have support for tablet/mobile breakpoints in order to be considered