mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 10:38:32 +08:00
fix: marketplace page header jitter when it in sticky status (#38832)
This commit is contained in:
parent
0e84444809
commit
41683013e3
@ -101,6 +101,9 @@ const Description = ({
|
||||
const header = headerRef.current
|
||||
if (!container || !header) return
|
||||
|
||||
const previousOverflowAnchor = container.style.overflowAnchor
|
||||
container.style.overflowAnchor = 'none'
|
||||
|
||||
let maxHeaderHeight = 0
|
||||
let lastAppliedOffset = 0
|
||||
const updateOffset = () => {
|
||||
@ -111,12 +114,8 @@ const Description = ({
|
||||
const baseScrollableTop = Math.max(0, currentScrollableTop - lastAppliedOffset)
|
||||
const shouldCompensate = baseScrollableTop <= maxHeaderHeight
|
||||
const nextOffset = shouldCompensate ? collapsedHeight : 0
|
||||
const offsetDelta = nextOffset - lastAppliedOffset
|
||||
|
||||
if (nextOffset > 0) {
|
||||
container.style.setProperty('--marketplace-header-collapse-offset', `${nextOffset}px`)
|
||||
if (offsetDelta !== 0 && container.scrollTop > 0)
|
||||
container.scrollTop = Math.max(0, container.scrollTop + offsetDelta)
|
||||
} else {
|
||||
container.style.removeProperty('--marketplace-header-collapse-offset')
|
||||
}
|
||||
@ -129,16 +128,17 @@ const Description = ({
|
||||
if (typeof ResizeObserver === 'undefined') {
|
||||
return () => {
|
||||
container.style.removeProperty('--marketplace-header-collapse-offset')
|
||||
container.style.overflowAnchor = previousOverflowAnchor
|
||||
}
|
||||
}
|
||||
|
||||
const observer = new ResizeObserver(updateOffset)
|
||||
observer.observe(header)
|
||||
observer.observe(container)
|
||||
|
||||
return () => {
|
||||
observer.disconnect()
|
||||
container.style.removeProperty('--marketplace-header-collapse-offset')
|
||||
container.style.overflowAnchor = previousOverflowAnchor
|
||||
}
|
||||
}, [isMarketplacePlatform, scrollContainerId])
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user