Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resize handler percision mismatch #570

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix resize handler percision mismatch
  • Loading branch information
hamidrezahanafi committed Sep 19, 2023
commit 919a9f7a132b23a0a7e9a15597dd435f861d2569
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