UNPKG

@barba/core

Version:

Create badass, fluid and smooth transition between your website's pages

77 lines (76 loc) 1.91 kB
/** * @barba/core/modules/store * <br><br> * ## Transitions store. * * - Resolve transition * - Manage rules * * @module core/modules/store * @preferred */ /***/ import { ITransitionAppear, ITransitionData, ITransitionFilters, ITransitionPage } from '../defs'; import { Logger } from './Logger'; export declare class Store { logger: Logger; /** * All registered transitions. */ all: ITransitionPage[]; /** * "Appear only" registered transitions. */ appear: ITransitionAppear[]; /** * Rules for transition resolution. * * Defaults: * * - namespace * - custom */ private _rules; /** * Init store. */ constructor(transitions?: ITransitionPage[]); /** * Add rule or transition. */ add(type: 'rule' | 'transition', data: any): void; /** * Resolve transition. */ resolve(data: ITransitionData, filters?: ITransitionFilters): ITransitionAppear | ITransitionPage; /** * ### Update store. * * - Reorder transition by priorities * - Get wait indicator * - Get appear transitions */ update(): void; /** * ### Check if transition apply. * * Based on rule, page data and optional direction: * * 1. transition has no rule "property": * - always returns true * 2. transition has rule "property": * - "strings" should be present on both side (transition + page) and match * - "function" should return true */ private _check; /** * ### Calculate transition priority. * * Based on: * * - rule "position" (index) give tens, hundreds, thousands, … * - from/to properties give units (0, 1 or 2) */ private _calculatePriority; private _addPriority; }