Skip to content

Commit

Permalink
feat(types): make VirtualOptions generic (#6852)
Browse files Browse the repository at this point in the history
  • Loading branch information
Magda98 authored Jul 25, 2023
1 parent e1b7254 commit 068ee68
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/types/modules/virtual.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface VirtualMethods {
export interface VirtualMethods<T = any> {
/**
* Object with cached slides HTML elements
*/
Expand All @@ -17,7 +17,7 @@ export interface VirtualMethods {
/**
* Array with slide items passed by `virtual.slides` parameter
*/
slides: any[];
slides: T[];

/*
* Methods
Expand Down Expand Up @@ -59,7 +59,7 @@ export interface VirtualMethods {

export interface VirtualEvents {}

export interface VirtualData {
export interface VirtualData<T> {
/**
* slides left/top offset in px
*/
Expand All @@ -75,10 +75,10 @@ export interface VirtualData {
/**
* array with slide items to be rendered
*/
slides: any[];
slides: T[];
}

export interface VirtualOptions {
export interface VirtualOptions<T = any> {
/**
* Whether the virtual slides are enabled
*
Expand All @@ -90,7 +90,7 @@ export interface VirtualOptions {
*
* @default []
*/
slides?: any[];
slides?: T[];
/**
* Enables DOM cache of rendering slides html elements. Once they are rendered they will be saved to cache and reused from it.
*
Expand All @@ -114,7 +114,7 @@ export interface VirtualOptions {
*
* @default null
*/
renderSlide?: (slide: any, index: any) => any | null;
renderSlide?: (slide: T, index: any) => any | null;
/**
* Function for external rendering (e.g. using some other library to handle DOM manipulations and state like React.js or Vue.js). As an argument it accepts `data` object with the following properties:
*
Expand All @@ -125,7 +125,7 @@ export interface VirtualOptions {
*
* @default null
*/
renderExternal?: (data: VirtualData) => any | null;
renderExternal?: (data: VirtualData<T>) => any | null;
/**
* When enabled (by default) it will update Swiper layout right after renderExternal called. Useful to disable and update swiper manually when used with render libraries that renders asynchronously
*
Expand Down

0 comments on commit 068ee68

Please sign in to comment.