Gestures
Layout
PullToRefresh
A pull-down gesture at the top of a scroll container that starts a refresh. Use it for feeds and lists on touch screens.
Install
import { PullToRefresh } from 'vael-ui'Playground
- Row 1
- Row 2
- Row 3
- Row 4
- Row 5
- Row 6
- Row 7
- Row 8
Usage
<script setup lang="ts">
import { PullToRefresh } from 'vael-ui'
async function refresh() {
await new Promise((resolve) => setTimeout(resolve, 1000))
}
</script>
<template>
<PullToRefresh :on-refresh="refresh">
<ul>
<li v-for="n in 8" :key="n">Row {{ n }}</li>
</ul>
</PullToRefresh>
</template>Motion New
PullToRefresh: its appearance and states.
<PullToRefresh
:motion="{ states: { pulling: { root: { scale: 1.04 } } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | rootindicator | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
states | pullingrefreshing | Sets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
It has no keyboard interaction of its own.
- The pull is touch and pointer only. Call the exposed
refresh()from a button to give keyboard and screen reader users the same action. - The pull zone, with its arrow, spinner and label, is
aria-hidden. An always-mountedrole="status"region reads “Refreshing…” and then “Updated”. - Without
scrollEl, the root scrolls, and it becomes a Tab stop while it overflows with nothing focusable inside.