From 919a9f7a132b23a0a7e9a15597dd435f861d2569 Mon Sep 17 00:00:00 2001 From: Hamidreza Hanafi Date: Tue, 19 Sep 2023 09:03:33 -0400 Subject: [PATCH] Fix resize handler percision mismatch --- packages/embla-carousel/src/components/ResizeHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/embla-carousel/src/components/ResizeHandler.ts b/packages/embla-carousel/src/components/ResizeHandler.ts index b860bb840..464fba826 100644 --- a/packages/embla-carousel/src/components/ResizeHandler.ts +++ b/packages/embla-carousel/src/components/ResizeHandler.ts @@ -1,7 +1,7 @@ import { AxisType } from './Axis' import { EmblaCarouselType } from './EmblaCarousel' import { EventHandlerType } from './EventHandler' -import { isBoolean, WindowType } from './utils' +import { isBoolean, mathAbs, WindowType } from './utils' type ResizeHandlerCallbackType = ( emblaApi: EmblaCarouselType, @@ -45,7 +45,7 @@ export function ResizeHandler( const lastSize = isContainer ? containerSize : slideSizes[slideIndex] const newSize = readSize(isContainer ? container : slides[slideIndex]) - if (lastSize !== newSize) { + if (mathAbs(newSize - lastSize) >= 0.2) { ownerWindow.requestAnimationFrame(() => { emblaApi.reInit() eventHandler.emit('resize')