Skip to content

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).

TypeScript
function createFlipList(container: HTMLElement, options?: FlipListOptions): FlipList
Parameters
NameTypeDefaultDescription
containerHTMLElement

The list element whose rows to animate.

options?FlipListOptions{}

See FlipListOptions.

ui/src/motion/flip-list.ts:169

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.

TypeScript
const FLIP_CLIP_ATTR = 'data-flip-clip'

ui/src/motion/flip-list.ts:44

Interfaces#

FlipLandingInterface#

The row a drag carried, landing: see FlipList.release.

TypeScript
interface FlipLanding
FlipLanding properties
NameTypeDescription
classNamestring

The class that makes a row look lifted; removed a frame into the landing.

fromHTMLElement

The dragged row's element when the drag ends (its key says which row lands).

ui/src/motion/flip-list.ts:76

FlipListInterface#

A FLIP controller over one list element.

TypeScript
interface FlipList
FlipList properties
NameTypeDescription
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 suspend, recording where the rows show now, so the next update glides them from there. prepare (a drag's: drop its transforms) runs right before that update measures, so no frame paints the rows at their old places in between. With no commit by the next frame, the update runs then on its own. landing: the row the drag carried (from, its element then), still lifted (className, the look of a dragged row): whatever carries it in that update (the row, or the copy flying it) starts with that class, which goes the next frame, so the row settles from lifted to resting by its own CSS transition.

snapshot(mode?: FlipMode) => void

Record the rows where they are now: right before a commit changes them (FlipSnapshot), so the next update starts each glide from where its row really was, whatever moved it since the last update. Skipped while a drag's release waits for its update (that record is the drag's). swap: the commit shows another view; an image of the list is taken too, for the update's fade-through.

suspend() => void

Stop animating (a drag moves the rows itself); updates only record until release.

update(animate?: boolean, mode?: FlipMode) => void

Measure the rows after a commit and animate what changed (animate: false only records). With nothing recorded yet (a list that just mounted), an animated update records once the list has painted instead.

ui/src/motion/flip-list.ts:84

FlipListOptionsInterface#

Options of createFlipList.

TypeScript
interface FlipListOptions
FlipListOptions properties
NameTypeDescription
isSticky?(el: HTMLElement) => boolean

A sticky header, measured at its unstuck place. Default: it carries data-flip-sticky.

keyOf?(el: HTMLElement) => string | null

A row's key, or null to skip it. Default: its data-flip-key.

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 <html>.

selector?string

The rows to track. Default [data-flip-key].

ui/src/motion/flip-list.ts:54

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).

TypeScript
type FlipMode = 'list' | 'fold' | 'swap'

ui/src/motion/flip-list.ts:73