barba.js

在网站页面之间创建流畅、平滑的过渡效果。「Create badass, fluid and smooth transition between your website's pages.」

Github星跟蹤圖

barba.js [v2]

stability-wip
CircleCI
Coverage Status
Commitizen friendly
Conventional Commits
lerna
License
All Contributors
Slack channel

Invite link to slack channel

Barba.js is a small (7kb minified and compressed) and easy-to-use library that helps you create fluid and smooth transitions between your website's pages.

It helps reduce the delay between your pages, minimize browser HTTP requests and enhance your user's web experience.

Documentation

What's new?

  • Simplified API
  • Hook sytem for transitions and views
  • Transition resolution: declare your transitions and let Barba pick the right one
  • Use of data-barba attributes
  • Sync mode
  • Plugin system
    • @barba/router: use of routes for transition resolution
    • @barba/css: automatic addition of CSS classes
    • @barba/prefetch: automatic pages prefetching (and caching), based on viewport
    • @barba/head: update your <head> (coming soon)
    • @barba/preset: ready-to-use basic transitions pack (fade, slide, …) (coming soon)

Main changes (TL;DR)

  • Barba now use data-barba-* attributes:
  • 2 main methods:
    • barba.init() for transitions, views and Barba core settings
    • barba.use() for plugins (router, css, prefetch, etc.)
  • Transitions:
    • are plain JS objects
    • are declared via the barba.init({ transitions })
    • use "hooks" corresponding to animation steps
      • hooks can be synchronous or asynchronous (via this.async() or Promise based)
      • all hooks receive same data argument
    • use "rules" to select which transition to use
      • default rules are namespace and custom
      • @barba/router adds route rule
      • they can be combined within from and to properties
  • Views:
    • are plain JS objects
    • are declared via the barba.init({ views })
    • use a subset of animation "hooks":
      • beforeOnce, afterOnce, beforeLeave, afterLeave, beforeEnter, afterEnter
      • receive the same data argument
  • Sync mode will start leave and enter transitions concurrently

How it works?

BarbaJS make your site work like a Single Page Application (SPA), allowing you to create smooth transitions without having to reload the whole site, reducing load delay, browser requests and enhancing user's web experience. Here is a small lifecycle diagram that describe Barba's main concept when navigating between two pages.

Barba lifecycle diagram

Note that using the sync property will end in a different page lifecycle, see https://barba.js.org/docs/userguide/syntax/#Sync-mode

How to contribute

If you want to report a bug or if you just want to request for a new feature/improvement, please follow those instructions before.

Thanks for taking time to contribute to Barba :tada: :+1:

Contributors

Next steps

  • CI setup (PR, publish, …)
  • Write manual documentation
  • Generate code documentation
  • New website
  • More Testing, debugging, fixing, testing…

主要指標

概覽
名稱與所有者barbajs/barba
主編程語言TypeScript
編程語言JavaScript (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2015-11-12 20:08:53
推送於2024-12-02 22:33:28
最后一次提交
發布數94
最新版本名稱v2.10.3 (發布於 )
第一版名稱0.0.5 (發布於 )
用户参与
星數12.3k
關注者數135
派生數476
提交數1k
已啟用問題?
問題數665
打開的問題數12
拉請求數61
打開的拉請求數0
關閉的拉請求數27
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?