fix: 💨
This commit is contained in:
parent
a9caf9d5ad
commit
ad3df9b037
4 changed files with 18 additions and 14 deletions
|
|
@ -219,7 +219,7 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
|
||||||
}
|
}
|
||||||
setCurrentPrimaryPage(page)
|
setCurrentPrimaryPage(page)
|
||||||
if (needScrollToTop) {
|
if (needScrollToTop) {
|
||||||
PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop()
|
PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop('smooth')
|
||||||
}
|
}
|
||||||
if (isSmallScreen) {
|
if (isSmallScreen) {
|
||||||
clearSecondaryPages()
|
clearSecondaryPages()
|
||||||
|
|
@ -231,7 +231,7 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
|
||||||
if (isCurrentPage(prevStack, url)) {
|
if (isCurrentPage(prevStack, url)) {
|
||||||
const currentItem = prevStack[prevStack.length - 1]
|
const currentItem = prevStack[prevStack.length - 1]
|
||||||
if (currentItem?.ref?.current) {
|
if (currentItem?.ref?.current) {
|
||||||
currentItem.ref.current.scrollToTop()
|
currentItem.ref.current.scrollToTop('instant')
|
||||||
}
|
}
|
||||||
return prevStack
|
return prevStack
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,13 @@ const PrimaryPageLayout = forwardRef(
|
||||||
useImperativeHandle(
|
useImperativeHandle(
|
||||||
ref,
|
ref,
|
||||||
() => ({
|
() => ({
|
||||||
scrollToTop: () => {
|
scrollToTop: (behavior: ScrollBehavior = 'smooth') => {
|
||||||
|
setTimeout(() => {
|
||||||
if (scrollAreaRef.current) {
|
if (scrollAreaRef.current) {
|
||||||
return scrollAreaRef.current.scrollTo({ top: 0, behavior: 'smooth' })
|
return scrollAreaRef.current.scrollTo({ top: 0, behavior })
|
||||||
}
|
}
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior })
|
||||||
|
}, 10)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ const SecondaryPageLayout = forwardRef(
|
||||||
useImperativeHandle(
|
useImperativeHandle(
|
||||||
ref,
|
ref,
|
||||||
() => ({
|
() => ({
|
||||||
scrollToTop: () => {
|
scrollToTop: (behavior: ScrollBehavior = 'smooth') => {
|
||||||
|
setTimeout(() => {
|
||||||
if (scrollAreaRef.current) {
|
if (scrollAreaRef.current) {
|
||||||
return scrollAreaRef.current.scrollTo({ top: 0, behavior: 'smooth' })
|
return scrollAreaRef.current.scrollTo({ top: 0, behavior })
|
||||||
}
|
}
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior })
|
||||||
|
}, 10)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
|
|
@ -46,7 +48,7 @@ const SecondaryPageLayout = forwardRef(
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSmallScreen) {
|
if (isSmallScreen) {
|
||||||
setTimeout(() => window.scrollTo({ top: 0 }), 0)
|
setTimeout(() => window.scrollTo({ top: 0 }), 10)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
|
||||||
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
|
|
@ -120,7 +120,7 @@ export type TNoteListMode = 'posts' | 'postsAndReplies' | 'you'
|
||||||
|
|
||||||
export type TNotificationType = 'all' | 'mentions' | 'reactions' | 'zaps'
|
export type TNotificationType = 'all' | 'mentions' | 'reactions' | 'zaps'
|
||||||
|
|
||||||
export type TPageRef = { scrollToTop: () => void }
|
export type TPageRef = { scrollToTop: (behavior?: ScrollBehavior) => void }
|
||||||
|
|
||||||
export type TNip66RelayInfo = TRelayInfo & {
|
export type TNip66RelayInfo = TRelayInfo & {
|
||||||
url: string
|
url: string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue