Skip to content

Commit

Permalink
fix: show arrows carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
g-francesca committed Aug 20, 2024
1 parent bf40ee9 commit d5e119f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@

.sources-wrapper {
display: flex;
gap: var(--spacing-s, $spacing-s);
overflow-x: auto;
scrollbar-width: none;
position: relative;
Expand All @@ -108,6 +107,7 @@
position: relative;
overflow: hidden;
width: pxToRem(195);
margin-right: var(--spacing-s, $spacing-s);
flex-grow: 0;
flex-shrink: 0;
text-decoration: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ export class OramaChatAssistentMessage {
const carousel = this.carouselSourceRef
const slide = carousel.querySelector('.source')
const slideWidth = slide.clientWidth
carousel.scrollLeft = carousel.scrollLeft + (next ? slideWidth : -slideWidth)
const slideMargin = Number.parseInt(window.getComputedStyle(slide).marginRight, 10)
const slideTotalWidth = slideWidth + slideMargin
carousel.scrollLeft = carousel.scrollLeft + (next ? slideTotalWidth : -slideTotalWidth)

// TO be fixed
if (next) {
if (this.carouselEnd) return
this.carouselStart = false
this.carouselEnd = carousel.scrollLeft === carousel.scrollWidth - carousel.clientWidth
this.carouselEnd =
Number.parseInt(carousel.scrollLeft + slideTotalWidth.toString()) ===
carousel.scrollWidth - carousel.offsetWidth
} else {
this.carouselStart = carousel.scrollLeft - slideWidth === 0
if (this.carouselStart) return
this.carouselStart = carousel.scrollLeft - slideTotalWidth === 0
this.carouselEnd = false
}
}
Expand Down

0 comments on commit d5e119f

Please sign in to comment.