![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
libpag-lite-miniprogram
Advanced tools
官网 | English | Web 版本 | Web lite版本 | 小程序版本 | 小程序lite版本
libpag-lite-miniprogram 是 libpag 在微信小程序平台的简化版 SDK
点击菜单“文件” -> “导出” -> “PAG File(Panel)...”,选择需要导出的合成,点击设置按钮,在根节点勾选BMP,导出全BMP预合成的PAG文件。
可以下载 PAGViewer 打开 PAG 文件,点击"视图"->"显示 编辑面板",在编辑面板中我们能看到 Video 的数量,当 Video数量为 1 时,即为单一 BMP 序列帧。
$ npm install libpag-lite-miniprogram
点击「微信开发者工具」- 「工具」- 「构建npm」,进行小程序 npm 依赖构建
<!-- index.wxml -->
<canvas type="webgl" id="pag" style="width: 300px; height:300px;"></canvas>
// index.js
import { PAGView } from 'libpag-lite-miniprogram';
Page({
onReady() {
wx.createSelectorQuery().select('#pag').node().exec(async(res) => {
const canvas = res.node
wx.request({
url,
method: 'GET',
responseType: 'arraybuffer',
success(res) {
const pagView = PAGView.init(res.data, canvas);
pagView.play();
},
});
})
}
})
因为 PAG 解码的时候用到了 VideoDecoder,而 VideoDecoder 的解码并不支持 blobURL,所以会把 BMP 预合成的视频数据缓存在本地。
为避免PAG的缓存把用户缓存目录内存占用过高,建议在不需要使用PAG的时候,调用 clearCache()
方法进行缓存清理。
创建 View 实例
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
data | ArrayBuffer | PAG文件 | Y | |
canvas | HTMLCanvasElement | 用于绘图的 canvas 标签 | Y |
播放
暂停
停止
销毁
是否播放中
是否已经销毁
动画持续时间,单位:秒
设置动画重复的次数
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
repeatCount | number | 设置动画重复的次数,如为 0 动画则无限播放。 | 1 | N |
返回当前播放进度位置,取值范围为 0.0 到 1.0
设置播放进度位置
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
progress | number | 设置播放进度位置,取值范围为 0.0 到 1.0 | Y |
返回当前填充模式
指定内容的填充模式
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
scaleMode | ScaleMode | 缩放模式,可选值:None 、Stretch 、 LetterBox 和 Zoom | LetterBox | N |
增加事件监听
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
eventName | string | 事件名称 | Y | |
listener | funtion | 监听器 | Y |
事件列表:
名称 | 说明 |
---|---|
onAnimationStart | 动画开始播放 |
onAnimationCancel | 动画取消播放 |
onAnimationEnd | 动画结束播放 |
onAnimationRepeat | 动画循环播放 |
增加事件监听
名称 | 类型 | 说明 | 默认值 | 必传 |
---|---|---|---|---|
eventName | string | 事件名称 | Y | |
listener | funtion | 监听器,如不传入 listener 则移除该事件下所有监听器 | undefined | N |
清理 PAG 产生的缓存
键 | 类型 | 说明 | 默认值 |
---|---|---|---|
FPS | number | 过去一秒内渲染帧数量 | 0 |
getFrame | number | 当前帧获取耗时,单位 ms | 0 |
draw | number | 当前帧渲染耗时,单位 ms | 0 |
decodePAGFile | number | PAG 文件解码耗时,单位 ms | 0 |
coverMP4 | number | 合成 MP4 耗时,单位 ms | 0 |
writeFile | number | 写入文件耗时,单位 ms | 0 |
createDecoder | number | 创建解码器耗时,单位 ms |
填充模式
键 | 类型 | 值 | 说明 |
---|---|---|---|
None | String | None | 不缩放 |
Stretch | String | Stretch | 拉伸内容到适应画布 |
LetterBox | String | LetterBox | 根据原始比例缩放内容 |
Zoom | String | Zoom | 根据原始比例被缩放适应,一个轴会被裁剪 |
FAQs
Portable Animated Graphics lite.
The npm package libpag-lite-miniprogram receives a total of 4 weekly downloads. As such, libpag-lite-miniprogram popularity was classified as not popular.
We found that libpag-lite-miniprogram demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.