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(types): fixed SwiperModule, slideTo, effectInit types #7428

Merged
merged 2 commits into from May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/swiper-effect-utils.d.ts
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
@@ -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
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