humanmade/lottie-lite

WordPress 的轻量级 Lottie 动画扩展

安装次数: 272

依赖者: 0

建议者: 0

安全: 0

星标: 3

关注者: 12

分支: 0

开放问题: 5

语言:JavaScript

类型:wordpress-plugin

1.2.5 2024-09-17 22:43 UTC

This package is auto-updated.

Last update: 2024-09-17 22:43:53 UTC


README

添加对 Lottie 动画的支持,增强以下块的功能

  • 核心图片块
  • 核心封面块
  • 核心媒体与文本块

允许覆盖或用动画替换图片。

安装

  1. GitHub 仓库 下载插件。
  2. 将插件上传到您网站的 wp-content/plugins 目录。
  3. 在 WordPress 管理界面激活插件。

高级使用

该插件在增强的块上公开了 DotLottie 网络播放器对象。这使得您可以与播放器交互并控制动画。

要访问播放器对象,您可以使用以下 JavaScript 代码

function doStuff(player) {
    // Do stuff with the player object
}

// Wait for the player to be ready as they may be loaded asynchronously,
// depending on the block's visibility and whether the image is lazy-loaded.
document.querySelectorAll( '[data-lottie]' ).forEach( ( element ) => {
    if ( element.lottie ) {
        doStuff( element.lottie );
    } else {
        element.addEventListener( 'lottieReady', () => {
            doStuff( element.lottie );
        } );
    }
} );

DotLottie 网络播放器的完整文档可以在这里找到

https://developers.lottiefiles.com/docs/dotlottie-player/dotlottie-web/