From f593d327a38d32ec9ca0c0918279dac820168159 Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Mon, 8 Nov 2021 17:31:29 +0100 Subject: [PATCH] `getCurrentBreakpoint`: Fixed media matching issue. --- package.json | 2 +- webflow/getCurrentBreakpoint.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 51b3602..e22efce 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/webflow/getCurrentBreakpoint.ts b/webflow/getCurrentBreakpoint.ts index 697b709..3d0d370 100644 --- a/webflow/getCurrentBreakpoint.ts +++ b/webflow/getCurrentBreakpoint.ts @@ -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'; };