mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-14 17:51:38 +00:00
## Summary <!-- One sentence describing what changed and why. --> Polish and fix UI for new website ## Changes - **What**: <!-- Core functionality added/modified --> - [x] update about video - [x] update Moment factory story content - [x] update homepage visual - [x] update customer story visual - [x] put images and videos to bucket ## Review Focus <!-- Critical design decisions or edge cases that need attention --> <!-- If this PR fixes an issue, uncomment and update the line below --> <!-- Fixes #ISSUE_NUMBER --> ## Screenshots (if applicable) <!-- Add screenshots or video recording to help explain your changes --> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11363-feat-website-Polish-and-fix-UI-3466d73d365081f895aff84b594450c9) by [Unito](https://www.unito.io) --------- Co-authored-by: DrJKL <DrJKL0424@gmail.com> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Alexander Brown <drjkl@comfy.org> Co-authored-by: github-actions <github-actions@github.com>
85 lines
1.7 KiB
TypeScript
85 lines
1.7 KiB
TypeScript
import type Lenis from 'lenis'
|
|
|
|
import { gsap, ScrollTrigger } from './gsapSetup'
|
|
import { prefersReducedMotion } from '../composables/useReducedMotion'
|
|
|
|
let lenis: Lenis | undefined
|
|
|
|
let initialized = false
|
|
|
|
export async function initSmoothScroll() {
|
|
if (initialized) return
|
|
initialized = true
|
|
|
|
if (prefersReducedMotion()) return
|
|
|
|
const ua = navigator.userAgent
|
|
const isWindows = /Windows/.test(ua)
|
|
const isLinux = /Linux/.test(ua) && !/Android/.test(ua)
|
|
if (!isWindows && !isLinux) return
|
|
|
|
const { default: Lenis } = await import('lenis')
|
|
|
|
lenis = new Lenis()
|
|
lenis.on('scroll', ScrollTrigger.update)
|
|
gsap.ticker.add((time) => lenis!.raf(time * 1000))
|
|
gsap.ticker.lagSmoothing(0)
|
|
}
|
|
|
|
export interface ScrollToOptions {
|
|
offset?: number
|
|
duration?: number
|
|
immediate?: boolean
|
|
onComplete?: () => void
|
|
}
|
|
|
|
export function scrollTo(
|
|
target: HTMLElement | number,
|
|
options: ScrollToOptions = {}
|
|
) {
|
|
const { offset = 0, duration = 0.6, immediate = false, onComplete } = options
|
|
|
|
if (lenis) {
|
|
lenis.scrollTo(target, {
|
|
offset,
|
|
duration: immediate ? 0 : duration,
|
|
immediate,
|
|
onComplete
|
|
})
|
|
return
|
|
}
|
|
|
|
const y =
|
|
typeof target === 'number'
|
|
? target + offset
|
|
: target.getBoundingClientRect().top + window.scrollY + offset
|
|
|
|
if (immediate) {
|
|
window.scrollTo(0, y)
|
|
onComplete?.()
|
|
return
|
|
}
|
|
|
|
gsap.to(window, {
|
|
scrollTo: { y, autoKill: false },
|
|
duration,
|
|
ease: 'power2.inOut',
|
|
onComplete
|
|
})
|
|
}
|
|
|
|
export function stopScroller() {
|
|
lenis?.stop()
|
|
}
|
|
|
|
export function startScroller() {
|
|
lenis?.start()
|
|
}
|
|
|
|
export function cancelScroll() {
|
|
if (lenis?.isScrolling) {
|
|
lenis.stop()
|
|
lenis.start()
|
|
}
|
|
}
|