Skip to content

Commit ac5ddc2

Browse files
committed
feat(Helpers): add smoothScrollToTop function for enhanced scrolling experience
1 parent 19d5ed0 commit ac5ddc2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Shared/Helpers.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ReactElement, useEffect, useRef, useState } from 'react'
1919
import { PromptProps } from 'react-router-dom'
2020
import { StrictRJSFSchema } from '@rjsf/utils'
2121
import Tippy from '@tippyjs/react'
22+
import { animate } from 'framer-motion'
2223
import moment from 'moment'
2324
import { nanoid } from 'nanoid'
2425
import { Pair } from 'yaml'
@@ -700,3 +701,16 @@ export const getAppDetailsURL = (appId: number | string, envId?: number | string
700701
}
701702
return baseURL
702703
}
704+
705+
export const smoothScrollToTop = (scrollContainer: HTMLElement, targetPosition: number) => {
706+
const start = scrollContainer.scrollTop
707+
708+
const controls = animate(start, targetPosition, {
709+
ease: [0.33, 1, 0.68, 1],
710+
onUpdate: (value) => {
711+
scrollContainer.scrollTop = value
712+
},
713+
})
714+
715+
return controls
716+
}

0 commit comments

Comments
 (0)