motion/flip-list
import { … } from 'zidane-ui'ui/src/motion/flip-list.ts
Functions#
createFlipListFunction#
Create a FLIP controller for container (the scrolling list element; it must be positioned,
as the stand-ins are placed in it).
function createFlipList(container: HTMLElement, options?: FlipListOptions): FlipListParameters
| Name | Type | Default | Description |
|---|---|---|---|
| container | HTMLElement | The list element whose rows to animate. | |
| options? | FlipListOptions | {} | See |
Returns
Constants#
FLIP_CLIP_ATTRConstant#
Put on a box that clips its rows (a fold): a row leaving it for another flies over both, as between scroll areas.
const FLIP_CLIP_ATTR = 'data-flip-clip'Interfaces#
FlipLandingInterface#
The row a drag carried, landing: see FlipList.release.
interface FlipLandingProperties
| Name | Type | Description |
|---|---|---|
| className | string | The class that makes a row look lifted; removed a frame into the landing. |
| from | HTMLElement | The dragged row's element when the drag ends (its key says which row lands). |
FlipListInterface#
A FLIP controller over one list element.
interface FlipListProperties
| Name | Type | Description |
|---|---|---|
| dispose | () => void | Stop every animation and remove the stand-ins. |
| recordLater | () => void | Drop the record and take a new one once the list has painted: a commit with nothing to show (no measure in its frame). |
| release | (prepare?: () => void, landing?: FlipLanding) => void | Resume after |
| snapshot | (mode?: FlipMode) => void | Record the rows where they are now: right before a commit changes them ( |
| suspend | () => void | Stop animating (a drag moves the rows itself); updates only record until |
| update | (animate?: boolean, mode?: FlipMode) => void | Measure the rows after a commit and animate what changed ( |
FlipListOptionsInterface#
Options of createFlipList.
interface FlipListOptionsProperties
| Name | Type | Description |
|---|---|---|
| isSticky? | (el: HTMLElement) => boolean | A sticky header, measured at its unstuck place. Default: it carries |
| keyOf? | (el: HTMLElement) => string | null | A row's key, or null to skip it. Default: its |
| maxChanges? | number | Past this many rows entering or leaving in one update, nothing animates. Default 40. |
| maxTravel? | number | The most a row travels on enter or exit, in px. Default 40. |
| prefs? | () => MotionPrefs | The motion switches. Default: read off |
| selector? | string | The rows to track. Default |
Types#
FlipModeType#
How an update plays: a list that changed (rows travel with their neighbours), a group folding around rows that stay, or a swap of what the list shows (a layout, a grouping, a filter: the whole list fades through).
type FlipMode = 'list' | 'fold' | 'swap'