Bootstrap

API baseTransitions

createTransition

function

createTransition(config?): TransitionWidget

Create a transition widget.

The widget will include a patch function, stores to track the animation states and a directive to apply the animation to an element.

Parameters

config?: PropsConfig<TransitionProps>

the props config of the transition

Returns

TransitionWidget

the transition widget


noAnimation

function

noAnimation(element, direction, animated, signal, context): void | Promise<void>

A transition to show / hide an element without any animated. It uses the HTML display attribute.

Parameters

element: SSRHTMLElement

the element to animate

direction: "show" | "hide"

the direction

animated: boolean

Whether the transition should be animated.

signal: AbortSignal

Signal allowing to stop the transition while running.

context: object

Context of the current transition. It is reused between calls if the previous transition was stopped while running on the same element.

Returns

void | Promise<void>


TransitionApi

interface

Interface representing the API for managing transitions of an element.

Properties
hide

hide: (animated?) => Promise<void>

Runs the transition to hide the element. It is equivalent to toggle with false as the first parameter.

Parameters

animated?: boolean

whether the transition should be animated. If the parameter is not defined, the animated property is used.

Returns

Promise<void>

A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was already running, the promise never completes.


show

show: (animated?) => Promise<void>

Runs the transition to show the element. It is equivalent to toggle with true as the first parameter.

Parameters

animated?: boolean

whether the transition should be animated. If the parameter is not defined, the animated property is used.

Returns

Promise<void>

A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was already running, the promise never completes.


toggle

toggle: (visible?, animated?) => Promise<void>

Runs the transition to show or hide the element depending on the first parameter.

Parameters

visible?: boolean

whether the element should be made visible or not. If the parameter is not defined, the opposite of the current visible property is used.

animated?: boolean

whether the transition should be animated. If the parameter is not defined, the animated property is used.

Returns

Promise<void>

A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was already running, the promise never completes.


TransitionDirectives

interface

Interface representing transition directives.

Properties
directive

directive: Directive

the transition directive


TransitionFn

type alias

TransitionFn: (element, direction, animated, signal, context) => Promise<void> | void

Function that implements a transition.

Parameters

element: SSRHTMLElement

direction: "show" | "hide"

animated: boolean

signal: AbortSignal

context: object

Returns

Promise<void> | void


TransitionProps

interface

Properties for configuring a transition.

Properties
animated

animated: boolean

Whether the transition should be animated.


animatedOnInit

animatedOnInit: boolean

If the element is initially visible, whether the element should be animated when first displayed.


initDone

initDone: null | boolean

Whether initialization is finished. It determines which setting between TransitionProps.animated and TransitionProps.animatedOnInit is used to enable or disable animations.

Remarks

If it is true, initialization is considered finished, and TransitionProps.animatedOnInit is no longer used. Otherwise, initialization is considered unfinished and TransitionProps.animatedOnInit is used instead of TransitionProps.animated. If it is null, it will be set to true automatically when the directive is called with a DOM element. If it is false, it will not be updated automatically.


onHidden

onHidden: () => void

Function to be called when the transition is completed and the element is not visible.

Returns

void


onShown

onShown: () => void

Function to be called when the transition is completed and the element is visible.

Returns

void


onVisibleChange

onVisibleChange: (visible) => void

Function to be called when the visible property changes.

Parameters

visible: boolean

new value of the visible property

Returns

void


transition

transition: TransitionFn

Transition to be called.


visible

visible: boolean

Whether the element should be visible when the transition is completed.


TransitionState

interface

Transition state.

Properties
element

element: null | HTMLElement

Reference to the DOM element.


elementPresent

elementPresent: boolean

Whether the element to be animated is present in the DOM.


hidden

hidden: boolean

Equals: ! visible && ! transitioning


shown

shown: boolean

Equals: visible && ! transitioning


transitioning

transitioning: boolean

Whether a transition is currently running.


visible

visible: boolean

Whether the element is visible or will be visible when the transition is completed.


TransitionWidget

type alias

TransitionWidget: Widget<TransitionProps, TransitionState, TransitionApi, TransitionDirectives>

Represents a widget that handles transitions.

Template

The properties required for the transition.

Template

The state management for the transition.

Template

The API interface for the transition.

Template

The directives used in the transition.