Skip to content

Commit 47b638d

Browse files
committed
2 parents d87ac0c + 1a4afe0 commit 47b638d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/core/breakpoints/getBreakpoint.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default function getBreakpoint(breakpoints, base = 'window', containerEl)
55
let breakpoint = false;
66

77
const window = getWindow();
8-
const currentWidth = base === 'window' ? window.innerWidth : containerEl.clientWidth;
98
const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
109

1110
const points = Object.keys(breakpoints).map((point) => {
@@ -20,7 +19,11 @@ export default function getBreakpoint(breakpoints, base = 'window', containerEl)
2019
points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
2120
for (let i = 0; i < points.length; i += 1) {
2221
const { point, value } = points[i];
23-
if (value <= currentWidth) {
22+
if (base === 'window') {
23+
if (window.matchMedia(`(min-width: ${value}px)`).matches) {
24+
breakpoint = point;
25+
}
26+
} else if (value <= containerEl.clientWidth) {
2427
breakpoint = point;
2528
}
2629
}

0 commit comments

Comments
 (0)