MCPcopy Index your code
hub / github.com/Splidejs/splide / Controller

Function Controller

src/js/components/Controller/Controller.ts:44–403  ·  view source on GitHub ↗
( Splide: Splide, Components: Components, options: Options )

Source from the content-addressed store, hash-verified

42 * @return A Controller component object.
43 */
44export function Controller( Splide: Splide, Components: Components, options: Options ): ControllerComponent {
45 const { on, emit } = EventInterface( Splide );
46 const { Move } = Components;
47 const { getPosition, getLimit, toPosition } = Move;
48 const { isEnough, getLength } = Components.Slides;
49 const { omitEnd } = options;
50 const isLoop = Splide.is( LOOP );
51 const isSlide = Splide.is( SLIDE );
52 const getNext = apply( getAdjacent, false );
53 const getPrev = apply( getAdjacent, true );
54
55 /**
56 * The current index.
57 */
58 let currIndex = options.start || 0;
59
60 /**
61 * The latest end index.
62 */
63 let endIndex: number;
64
65 /**
66 * The previous index.
67 */
68 let prevIndex = currIndex;
69
70 /**
71 * The latest number of slides.
72 */
73 let slideCount: number;
74
75 /**
76 * The latest `perMove` value.
77 */
78 let perMove: number;
79
80 /**
81 * The latest `perMove` value.
82 */
83 let perPage: number;
84
85 /**
86 * Called when the component is mounted.
87 */
88 function mount(): void {
89 init();
90 on( [ EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED ], init );
91 on( EVENT_RESIZED, onResized );
92 }
93
94 /**
95 * Initializes some parameters.
96 * Needs to check the number of slides since the current index may be out of the range after refresh.
97 * The process order must be Elements -> Controller -> Move.
98 */
99 function init(): void {
100 slideCount = getLength( true );
101 perMove = options.perMove;

Callers

nothing calls this directly

Calls 3

EventInterfaceFunction · 0.90
applyFunction · 0.90
isMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…