Skip to content

UGC-19496: add loop parameter for swiper initialisation #201

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/libs/components/expanded-tile-swiper/expanded-swiper.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface ExpandedTileSettings {
widgetSelector: HTMLElement
expandedTileWrapper: Element
direction?: "horizontal" | "vertical"
loop?: boolean
}

/**
Expand Down Expand Up @@ -61,7 +62,8 @@ function initializeSwiperForExpandedTiles(paritalSettings: Partial<ExpandedTileS
widgetSelector,
expandedTileWrapper,
lookupAttr,
direction: paritalSettings.direction || "horizontal"
direction: paritalSettings.direction || "horizontal",
loop: paritalSettings.loop || false
}

if (isStory) {
Expand All @@ -81,7 +83,7 @@ function initalizeExpandedTile(settings: ExpandedTileSettings) {
nextButton: "swiper-expanded-button-next",
paramsOverrides: {
direction: direction,
loop: false,
loop: settings.loop || false,
slidesPerView: 1,
autoHeight: true,
keyboard: {
Expand Down Expand Up @@ -117,7 +119,8 @@ function initalizeStoryExpandedTile(settings: ExpandedTileSettings) {
prevButton: "swiper-expanded-button-prev",
nextButton: "swiper-expanded-button-next",
paramsOverrides: {
slidesPerView: "auto",
loop: settings.loop || false,
slidesPerView: 1,
autoHeight: true,
autoplay: {
delay: 5000
Expand Down Expand Up @@ -343,21 +346,24 @@ export function onTileExpand(tileId: string) {
const settings = {
initialTileId: tileId,
lookupAttr: lookupYtAttr,
direction: expandedTileSettings?.slide_direction
direction: expandedTileSettings?.slide_direction,
loop: expandedTileSettings?.loop
}
initializeSwiperForExpandedTiles(settings)
} else if (tiktokId) {
const lookupTiktokAttr: LookupAttr = { name: "data-tiktok-id", value: tiktokId }
const settings = {
initialTileId: tileId,
lookupAttr: lookupTiktokAttr,
direction: expandedTileSettings?.slide_direction
direction: expandedTileSettings?.slide_direction,
loop: expandedTileSettings?.loop
}
initializeSwiperForExpandedTiles(settings)
} else {
const settings = {
initialTileId: tileId,
direction: expandedTileSettings?.slide_direction
direction: expandedTileSettings?.slide_direction,
loop: expandedTileSettings?.loop
}
initializeSwiperForExpandedTiles(settings)
}
Expand Down
1 change: 1 addition & 0 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface ExpandedTileOptions {
show_add_to_cart: boolean
show_carousel_grouping: boolean
slide_direction?: "horizontal" | "vertical"
loop?: boolean
}

export interface InlineTileOptions {
Expand Down
Loading