Skip to content

Commit

Permalink
Merge pull request #570 from hamidrezahanafi/hrh.fixresizehandler
Browse files Browse the repository at this point in the history
Fix resize handler percision mismatch
  • Loading branch information
davidjerleke authored Sep 19, 2023
2 parents d0f889d + 919a9f7 commit be7da22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/embla-carousel/src/components/ResizeHandler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit be7da22

Please sign in to comment.