Skip to content

Commit

Permalink
getCurrentBreakpoint: Fixed media matching issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Nov 8, 2021
1 parent 46b1b72 commit f593d32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finsweet/ts-utils",
"version": "0.22.0",
"version": "0.22.1",
"description": "Typescript utils for custom Webflow projects.",
"main": "index.ts",
"module": "index.ts",
Expand Down
6 changes: 5 additions & 1 deletion webflow/getCurrentBreakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import type { WebflowBreakpoint } from './breakpoints';
* @returns A {@link WebflowBreakpoint} string.
*/
export const getCurrentBreakpoint = (): WebflowBreakpoint => {
for (const [breakpoint, mediaQuery] of WEBFLOW_BREAKPOINTS) if (window.matchMedia(mediaQuery)) return breakpoint;
for (const [breakpoint, mediaQuery] of WEBFLOW_BREAKPOINTS) {
if (window.matchMedia(mediaQuery).matches) {
return breakpoint;
}
}

return 'main';
};

0 comments on commit f593d32

Please sign in to comment.