Skip to content

Commit

Permalink
Fix: incorrect breakpoint detection in chrome devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
on3dd committed Jan 31, 2023
1 parent 5257937 commit 638df2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ class Carousel extends React.Component<CarouselProps, CarouselInternalState> {
Object.keys(responsive).forEach(item => {
const { breakpoint, items } = responsive[item];
const { max, min } = breakpoint;
if (window.innerWidth >= min && window.innerWidth <= max) {

const widths = [window.innerWidth];

if (window.screen && window.screen.width) {
widths.push(window.screen.width);
}

const screenWidth = Math.min(...widths);

if (screenWidth >= min && screenWidth <= max) {
this.setState({ slidesToShow: items, deviceType: item });
this.setContainerAndItemWidth(
items,
Expand Down

0 comments on commit 638df2b

Please sign in to comment.