@@ -5,9 +5,6 @@ import { add, clampValue, isObject, nextIndex, prevIndex, remove, uniq } from "@
55import * as dom from "./carousel.dom"
66import type { CarouselSchema } from "./carousel.types"
77
8- const DEFAULT_SLIDES_PER_PAGE = 1
9- const DEFAULT_SLIDES_PER_MOVE = "auto"
10-
118export const machine = createMachine < CarouselSchema > ( {
129 props ( { props } ) {
1310 return {
@@ -16,8 +13,8 @@ export const machine = createMachine<CarouselSchema>({
1613 orientation : "horizontal" ,
1714 snapType : "mandatory" ,
1815 loop : false ,
19- slidesPerPage : DEFAULT_SLIDES_PER_PAGE ,
20- slidesPerMove : DEFAULT_SLIDES_PER_MOVE ,
16+ slidesPerPage : 1 ,
17+ slidesPerMove : "auto" ,
2118 spacing : "0px" ,
2219 autoplay : false ,
2320 allowMouseDrag : false ,
@@ -85,12 +82,17 @@ export const machine = createMachine<CarouselSchema>({
8582 } ,
8683 } ,
8784
88- // watch: {
89- // slidesPerPage: ["setSnapPoints"],
90- // slidesPerMove: ["setSnapPoints"],
91- // page: ["scrollToPage", "focusIndicatorEl"],
92- // orientation: ["setSnapPoints", "scrollToPage"],
93- // },
85+ watch ( { track, action, context, prop } ) {
86+ track ( [ ( ) => prop ( "slidesPerPage" ) , ( ) => prop ( "slidesPerMove" ) ] , ( ) => {
87+ action ( [ "setSnapPoints" ] )
88+ } )
89+ track ( [ ( ) => context . get ( "page" ) ] , ( ) => {
90+ action ( [ "scrollToPage" , "focusIndicatorEl" ] )
91+ } )
92+ track ( [ ( ) => prop ( "orientation" ) ] , ( ) => {
93+ action ( [ "setSnapPoints" , "scrollToPage" ] )
94+ } )
95+ } ,
9496
9597 on : {
9698 "PAGE.NEXT" : {
0 commit comments