mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-18 22:52:37 +00:00
Add Lottie Files animation preview support
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>LottieFiles Preview</title>
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height:100%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#bm {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="bm"></div>
|
||||
<script src="https://unpkg.com/lottie-web/build/player/lottie.min.js"></script>
|
||||
<script src="lottie2html.js"></script>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* SvgaViewer: Provides SVGA animation preview with the following features.
|
||||
*
|
||||
* Requirements:
|
||||
* - Requires the following HTML structure:
|
||||
* <canvas id="canvas">
|
||||
* </canvas>
|
||||
* - SVGA file path is obtained via chrome.webview.hostObjects.external.GetPath()
|
||||
*
|
||||
* Features:
|
||||
* - Loads and plays SVGA animation files
|
||||
* - Uses SVGA.js library for parsing and playback
|
||||
* - Automatically starts playback after loading
|
||||
* - Handles asynchronous loading and mounting of SVGA files
|
||||
*/
|
||||
class LottieViewer {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Play Lottie files.
|
||||
* @async
|
||||
*/
|
||||
async play() {
|
||||
const path = await chrome.webview.hostObjects.external.GetPath();
|
||||
lottie.loadAnimation({
|
||||
container: document.getElementById('bm'),
|
||||
renderer: 'svg',
|
||||
loop: true,
|
||||
autoplay: true,
|
||||
path: 'https://' + path,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create the Lottie viewer and play
|
||||
new LottieViewer().play();
|
Reference in New Issue
Block a user