[General]: v8 to v9 Migration Guide (breaking changes) #1080
Replies: 3 comments 3 replies
-
|
Hello, I have some this.slider.on( 'init', () => this.classList.add( 'hello-world' ));How can I change the structure in version v9? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your efforts in creating Embla v9. |
Beta Was this translation helpful? Give feedback.
-
|
Migrated v8 -> v9 RC.1 without any trouble, seems to be working great :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Migration Guide (Breaking Changes Only)
This guide lists only breaking changes introduced in v9.0.0 and shows how to achieve the same behavior as in v8.6.0.
1. Core API
1.1 Method Renames (Breaking)
scrollNext()goToNext()scrollPrev()goToPrev()canScrollNext()canGoToNext()canScrollPrev()canGoToPrev()scrollTo(index, jump?, direction?)goTo(index, instant?, direction?)scrollSnapList()snapList()selectedScrollSnap()selectedSnap()previousScrollSnap()previousSnap()slidesNotInView()1.2 Updated Usage Examples
1.3 Replacement for slidesNotInView()
Note: The instant-scroll flag remains a boolean (jump → instant).
2. Events
2.1 General Event Changes (Breaking)
initevent has been removed.(api, event)withevent.typeandevent.detail.2.2 v8 → v9 Event Mapping
pointerDownpointerdownpointerMovepointermovepointerUppointerupslidesInViewslidesinviewslidesChangedslideschangedslideFocusStartslidefocusscrollscrollselectselectsettlesettleresizeresizereInitreinitdestroydestroyinit2.3 Full Event List (v9)
Events marked NEW did not exist in v8.
2.4 Event Usage Examples
2.5 No init Event Replacement
v8
v9
2.6 Cancellable Events
falsefrom a handler cancels the event's internal handling.watchDragcallback maps to the cancellablepointerdownevent.3. Options (Breaking Renames)
startIndexstartSnapwatchDragdraggablepointerdownevent.watchResizeresizeresizeevent.watchSlidesslideChangesslideschangedis cancellable.watchFocusfocusslidefocusis cancellable.Example option mapping:
Callback migration:
watchDrag(fn)pointerdownfalsefrom handler to cancel pointer move/drag handling.watchResize(fn)resizefalsefrom handler to cancel Embla's internal resize handling.watchFocus(fn)slidefocusfalsefrom handler to cancel Embla's internal resize handling.watchSlides(fn)slideschangedfalsefrom handler to cancel Embla's internal resize handling.4. Plugins
4.1 Autoplay (embla-carousel-autoplay)
Breaking option changes:
playOnInit,stopOnFocusIn,stopOnInteraction,stopOnMouseEnterjump→instantdefaultInteraction: boolean4.2 Auto Scroll (embla-carousel-auto-scroll)
Breaking option changes:
playOnInit,stopOnFocusIn,stopOnInteraction,stopOnMouseEnterdefaultInteraction: boolean4.3 Auto Height (embla-carousel-auto-height)
Breaking change:
heightEvent: 'select' | 'slidesinview'(default:select).4.4 Class Names (embla-carousel-class-names)
draggingpointerDown5. Framework Wrappers
Vue (Breaking)
Svelte (Breaking)
Solid (Breaking)
createEmblaCarousel→useEmblaCarousel6. For Plugin Authors
6.1 Event Emission (Breaking)
6.2 Internal API Changes (Breaking)
internalEngine().ownerWindowinternalEngine().nodeHandler.ownerWindowinternalEngine().ownerDocumentinternalEngine().nodeHandler.ownerDocumentindexindexCurrentaxis.measureSizeaxis.getSizelimit.reachedMinpastMinBoundlimit.reachedMaxpastMaxBoundlimit.constrainclamp7. Version References
0848932HEADIf additional breaking changes are found, please open an issue with code references and this guide will be updated.
Beta Was this translation helpful? Give feedback.
All reactions