mirror of https://github.com/langgenius/dify.git
feat: optimize scroll bottom threshold
This commit is contained in:
parent
e759243c84
commit
cbd36e97ff
|
|
@ -27,6 +27,8 @@ import i18n from '@/i18n-config/i18next-config'
|
|||
import { postMarketplace } from '@/service/base'
|
||||
import type { PluginsFromMarketplaceResponse } from '@/app/components/plugins/types'
|
||||
|
||||
const SCROLL_BOTTOM_THRESHOLD = 100
|
||||
|
||||
export const useMarketplaceCollectionsAndPlugins = () => {
|
||||
const [queryParams, setQueryParams] = useState<CollectionsAndPluginsSearchParams>()
|
||||
const [marketplaceCollectionsOverride, setMarketplaceCollections] = useState<MarketplaceCollection[]>()
|
||||
|
|
@ -243,7 +245,7 @@ export const useMarketplaceContainerScroll = (
|
|||
scrollHeight,
|
||||
clientHeight,
|
||||
} = target
|
||||
if (scrollTop + clientHeight >= scrollHeight - 5 && scrollTop > 0)
|
||||
if (scrollTop + clientHeight >= scrollHeight - SCROLL_BOTTOM_THRESHOLD && scrollTop > 0)
|
||||
callback()
|
||||
}, [callback])
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import { PluginCategoryEnum } from '@/app/components/plugins/types'
|
|||
import { getMarketplaceListCondition } from '@/app/components/plugins/marketplace/utils'
|
||||
import { useAllToolProviders } from '@/service/use-tools'
|
||||
|
||||
const SCROLL_BOTTOM_THRESHOLD = 100
|
||||
|
||||
export const useMarketplace = (searchPluginText: string, filterPluginTags: string[]) => {
|
||||
const { data: toolProvidersData, isSuccess } = useAllToolProviders()
|
||||
const exclude = useMemo(() => {
|
||||
|
|
@ -81,7 +83,7 @@ export const useMarketplace = (searchPluginText: string, filterPluginTags: strin
|
|||
scrollHeight,
|
||||
clientHeight,
|
||||
} = target
|
||||
if (scrollTop + clientHeight >= scrollHeight - 5 && scrollTop > 0) {
|
||||
if (scrollTop + clientHeight >= scrollHeight - SCROLL_BOTTOM_THRESHOLD && scrollTop > 0) {
|
||||
const searchPluginText = searchPluginTextRef.current
|
||||
const filterPluginTags = filterPluginTagsRef.current
|
||||
if (hasNextPage && (!!searchPluginText || !!filterPluginTags.length))
|
||||
|
|
|
|||
Loading…
Reference in New Issue