Scroll Animation

将滚动与进度、视差、内容出现效果及主动定位连接。

适用场景

  • 当界面需要以下行为时使用 Scroll Animation:将滚动与进度、视差、内容出现效果及主动定位连接。

安装

选择安装方式,用法示例将同步更新导入路径。

$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/scroll-animation.json https://orvui.efu.me/r/smooth-scroll.json https://orvui.efu.me/r/scroll-progress.json https://orvui.efu.me/r/parallax.json https://orvui.efu.me/r/scroll-to.json https://orvui.efu.me/r/scroll-reveal.json

此示例还需要:

终端

首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。

示例

Smooth Scroll

smooth-scroll.vue

提供 Lenis 滚动,并通过 useSmoothScroll 共享偏移、速度与进度。

Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9
Section 10
Section 11
Section 12
Section 13
Section 14
Section 15
Section 16

Scroll Progress

scroll-progress.vue

将滚动进度呈现为横条或圆环,并可使用弹簧平滑数值。

Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9
Section 10
Section 11
Section 12
Section 13
Section 14
Section 15
Section 16
Section 17
Section 18

Parallax

parallax.vue

根据内容位置与指定速度系数,沿任一坐标轴偏移内容。

Scroll down ↓
Parallax
↑ Scroll up

Scroll To

scroll-to.vue

将当前滚动容器移动到指定元素、选择器或数值偏移。

Intro
Features
Pricing
FAQ

Scroll Reveal

scroll-reveal.vue

内容越过视口边界时显示,可选择仅执行一次或每次执行。

Scroll ↓
Spring slide
Blur in
Staggered by delay
Reveal once
End

状态与事件

此示例组合没有声明成对的受控属性与 update 事件。使用已列出的属性、原生事件和插槽组合内容;不要为它添加未公开的 v-model。

API 参考

Smooth Scroll

ScrollTo

to?
string | number | HTMLElement
props.target
target?
string | number | HTMLElement
—
offset?
number
—
duration?
number
—
disabled?
boolean
false

插槽

default
() => VNodeChild
#default

SmoothScroll

root?
boolean
true
lerp?
number
0.1
duration?
number
1.2
orientation?
"vertical" | "horizontal"
"vertical"
wheelMultiplier?
number
1
touch?
boolean
false
enabled?
boolean
true

插槽

default
() => VNodeChild
#default

Scroll Progress

variant?
"circle" | "bar"
"bar"
progress?
MotionValue<number>
fallback
spring?
boolean
true
position?
"top" | "bottom"
"top"
height?
number
2
fixed?
boolean
true
size?
number
40
thickness?
number
3

Parallax

speed?
number
0.3
axis?
"x" | "y"
"y"
container?
null | HTMLElement | Ref<HTMLElement | null, HTMLElement | null>
—
spring?
boolean
true

插槽

default
() => VNodeChild
#default

Scroll To

ScrollTo

to?
string | number | HTMLElement
props.target
target?
string | number | HTMLElement
—
offset?
number
—
duration?
number
—
disabled?
boolean
false

插槽

default
() => VNodeChild
#default

SmoothScroll

root?
boolean
true
lerp?
number
0.1
duration?
number
1.2
orientation?
"vertical" | "horizontal"
"vertical"
wheelMultiplier?
number
1
touch?
boolean
false
enabled?
boolean
true

插槽

default
() => VNodeChild
#default

Scroll Reveal

y?
number
16
blur?
number
8
duration?
number
0.6
delay?
number
0
once?
boolean
true
amount?
number | "some" | "all"
0.3
root?
null | HTMLElement | Ref<HTMLElement | null, HTMLElement | null>
—

插槽

default
() => VNodeChild
#default

无障碍

为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。

常见问题

如何配置 Scroll Animation?
通过 to、target、offset、duration、disabled 配置 Scroll Animation;API 表列出其类型与默认值。
如何连接到应用状态?
通过default 插槽提供内容,应用副作用由调用方管理。
可以在服务端渲染吗?
可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。

更新于