From 1e4b8d4d617626a5b4767d716c19bc57fe96b0ae Mon Sep 17 00:00:00 2001 From: Jayden Date: Thu, 25 Jun 2020 09:40:10 +0900 Subject: [PATCH] [swiper] Update swiper typings to v5.4 (#45330) * [swiper] Update swiper typings to v5.4 * [swiper] Update tests for changed typings --- types/swiper/index.d.ts | 11 +++++++++-- types/swiper/swiper-tests.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/types/swiper/index.d.ts b/types/swiper/index.d.ts index 0e54707a10..7b0e83e698 100644 --- a/types/swiper/index.d.ts +++ b/types/swiper/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Swiper 5.3 +// Type definitions for Swiper 5.4 // Project: https://github.com/nolimits4web/Swiper, http://www.idangero.us/swiper // Definitions by: Sebastián Galiano // Luca Trazzi @@ -61,10 +61,15 @@ export type AutoplayEvent = 'autoplayStart' | 'autoplayStop' | 'autoplay'; */ export type LazyLoadingEvent = 'lazyImageLoad' | 'lazyImageReady'; +/** + * Swiper hash-navigation event names. + */ +export type HashNavigationEvent = 'hashChange' | 'hashSet'; + /** * Swiper event names. */ -export type SwiperEvent = CommonEvent | PaginationEvent | AutoplayEvent | LazyLoadingEvent; +export type SwiperEvent = CommonEvent | PaginationEvent | AutoplayEvent | LazyLoadingEvent | HashNavigationEvent; /** * Swiper module types. @@ -1014,6 +1019,8 @@ export interface ThumbsOptions { swiper?: Swiper; slideThumbActiveClass?: string; thumbsContainerClass?: string; + multipleActiveThumbs?: boolean; + autoScrollOffset?: number; } export interface ZoomOptions { diff --git a/types/swiper/swiper-tests.ts b/types/swiper/swiper-tests.ts index 97918a8f2d..4c2dc78112 100644 --- a/types/swiper/swiper-tests.ts +++ b/types/swiper/swiper-tests.ts @@ -565,6 +565,10 @@ function hashNavigation() { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, + on: { + hashChange: () => null, + hashSet: () => null + } }); } @@ -811,3 +815,28 @@ function updateOnWindowResize() { }, }); } + +/** + * Thumbs + */ +function thumbs() { + const thumbsSwiper = new Swiper('.swiper-container-thumbs', { + slidesPerView: 5, + }); + const swiper = new Swiper(containerSelector, { + pagination: { + el: '.swiper-pagination', + }, + navigation: { + nextEl: '.swiper-button-next', + prevEl: '.swiper-button-prev', + }, + thumbs: { + swiper: thumbsSwiper, + slideThumbActiveClass: 'swiper-slide-thumb-active', + thumbsContainerClass: 'swiper-container-thumbs', + multipleActiveThumbs: true, + autoScrollOffset: 0 + } + }); +}