Skip to content

Commit

Permalink
fix(types): fixed SwiperModule, slideTo, effectInit types (#7428)
Browse files Browse the repository at this point in the history
* fix(types): fixed SwiperModule, slideTo, effectInit types

* fix(types): Update shared.d.ts
  • Loading branch information
9romise authored May 13, 2024
1 parent ced97a2 commit bc61bce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/swiper-effect-utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ declare const createShadow: (suffix?: string, slideEl: HTMLElement, side?: strin
declare const effectInit: (params: {
effect: string;
swiper: Swiper;
on?: () => void;
setTranslate?: () => void;
setTransition?: () => void;
on: () => void;
setTranslate: () => void;
setTransition: (duration: number) => void;
overwriteParams?: () => SwiperOptions;
perspective?: boolean;
perspective?: () => boolean;
recreateShadows?: () => void;
getEffectParams?: () => any;
getEffectParams?: () => { slideShadows?: boolean };
}) => void;

declare const effectTarget: (effectParams: any, slideEl: HTMLElement) => void;
Expand Down
14 changes: 11 additions & 3 deletions src/types/shared.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Swiper } from './index.d.ts';

export interface CSSSelector extends String {}

export interface SwiperModule {
name: string;
}
export type SwiperModule = (options: {
params: Swiper['params'];
swiper: Swiper;
extendParams: (obj: { [name: string]: any }) => void;
on: Swiper['on'];
once: Swiper['once'];
off: Swiper['off'];
emit: Swiper['emit'];
}) => void;
12 changes: 6 additions & 6 deletions src/types/swiper-class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slideNext(speed?: number, runCallbacks?: boolean): void;
slideNext(speed?: number, runCallbacks?: boolean): boolean;

/**
* Run transition to previous slide.
Expand All @@ -224,7 +224,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slidePrev(speed?: number, runCallbacks?: boolean): void;
slidePrev(speed?: number, runCallbacks?: boolean): boolean;

/**
* Run transition to the slide with index number equal to 'index' parameter for the
Expand All @@ -235,7 +235,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slideTo(index: number, speed?: number, runCallbacks?: boolean): void;
slideTo(index: number, speed?: number, runCallbacks?: boolean): boolean;

/**
* Does the same as .slideTo but for the case when used with enabled loop. So this
Expand All @@ -246,7 +246,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slideToLoop(index: number, speed?: number, runCallbacks?: boolean): void;
slideToLoop(index: number, speed?: number, runCallbacks?: boolean): Swiper;

/**
* Reset swiper position to currently active slide for the duration equal to 'speed'
Expand All @@ -256,7 +256,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slideReset(speed?: number, runCallbacks?: boolean): void;
slideReset(speed?: number, runCallbacks?: boolean): boolean;

/**
* Reset swiper position to closest slide/snap point for the duration equal to 'speed' parameter.
Expand All @@ -265,7 +265,7 @@ interface Swiper extends SwiperClass<SwiperEvents> {
* @param runCallbacks Set it to false (by default it is true) and transition will
* not produce transition events.
*/
slideToClosest(speed?: number, runCallbacks?: boolean): void;
slideToClosest(speed?: number, runCallbacks?: boolean): boolean;

/**
* Get dynamically calculated amount of slides per view, useful only when slidesPerView set to `auto`
Expand Down

0 comments on commit bc61bce

Please sign in to comment.