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: solves display bug of category chevron buttons #629

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions apps/web/src/components/Common/CategoryFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx'
import React, { useEffect, useState } from 'react'
import { Analytics, TRACK } from 'utils'
import { CREATOR_VIDEO_CATEGORIES } from 'utils/data/categories'
import useHorizontalScroll from 'utils/hooks/useHorizantalScroll'
import useHorizontalScroll from 'utils/hooks/useHorizontalScroll'

import ChevronLeftOutline from './Icons/ChevronLeftOutline'
import ChevronRightOutline from './Icons/ChevronRightOutline'
Expand Down Expand Up @@ -38,14 +38,16 @@ const CategoryFilters = () => {

const slide = (shift: number) => {
Analytics.track(TRACK.CLICK_CATEGORIES_SCROLL_BUTTON)

if (scrollRef.current) {
const scrolled = scrollRef.current.scrollLeft + shift
scrollRef.current.scrollLeft += shift
const scrollLeft = scrollRef.current.scrollLeft
setScrollX(scrollLeft === 0 ? 0 : scrollX + shift)

setScrollX(scrolled <= 0 ? 0 : scrollX + shift)

if (
Math.floor(
scrollRef.current.scrollWidth - scrollRef.current.scrollLeft
) <= scrollRef.current.offsetWidth
Math.floor(scrollRef.current.scrollWidth - scrolled) <=
scrollRef.current.offsetWidth
) {
setScrollEnd(true)
} else {
Expand Down