Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/upcoming/mobile-view-fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#### Fix

- Fallback to fixed width if mobile html element is missing
8 changes: 6 additions & 2 deletions src/js/modules/mobile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ export function isMobileAgent(agent = navigator.userAgent) {

/**
* Check if is a mobile based on selector being visible frontend
* Falls back to a screen-width check if the selector doesn't match an element
* @param {string} selector
* @param {number} breakpoint - width (px) used as the mobile fallback threshold when selector isn't found
* @returns {boolean}
* @example isMobileView()
*/
export function isMobileView(selector = '.mobileNavigation') {
return document.querySelector(selector).offsetParent !== null;
export function isMobileView(selector = '.mobileNavigation', breakpoint = 715) {
const element = document.querySelector(selector);

return element ? element.offsetParent !== null : window.innerWidth <= breakpoint;
}

/**
Expand Down
Loading